有关nginx 403

回复 收藏
以下是我的配置文件:

server
{
    listen 80;
    server_name www.zgf890213.com www.zgf5277.com www.zgf527714.com
    index index.html index.htm index.php;
    root /data/www/www1;
access_log /tmp/access.log zgf890213;
if ($host != 'www.zgf890213.com')
    {
        rewrite ^/(.*)$ www.zgf890213.com/$1 permanent;
    }
location ~ .*admin\.php$ {
        auth_basic "aminglinux auth";
        auth_basic_user_file /usr/local/nginx/conf/.htpasswd;
        include fastcgi_params;
        fastcgi_pass unix:/tmp/www.sock;
        #fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /data/www/www1$fastcgi_script_name;
        }

    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_pass unix:/tmp/www.sock;
        #fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /data/www/www1$fastcgi_script_name;
    }

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
    {
          expires      30d;
          access_log off;
          valid_referers none blocked *.zgf890213.com *.zgf5277.com *.zgf527714.com ;
         if ($invalid_referer)
       {
            return 403;
        }
    }
location ~ .*\.(js|css)?$
    {
          expires      12h;
          access_log off;
   }

}


请问配置i文件哪里写错了~?报403错误!
2016-08-23 01:17 举报
已邀请:
0

乐橙306

赞同来自:

1.把你配置文件备份 ,然后只留前半部分试试。

2.你的域名www.zgf890213.com无法访问,如果只能局域网访问,不如写成www.aaa.com  ,避免大伙误解

server
{
    listen 80;
    server_name www.zgf890213.com www.zgf5277.com www.zgf527714.com
    index index.html index.htm index.php;
    root /data/www/www1;
access_log /tmp/access.log zgf890213;
if ($host != 'www.zgf890213.com')
    {
        rewrite ^/(.*)$ www.zgf890213.com/$1 permanent;
    }
0

阿铭 管理员

赞同来自:

403 原因无外乎就那么几个:
1. 访问网站的时候,只写域名没写具体的url,而网站根目录下没有index.html index.php等文件,这时候就会403
2. nginx配置文件里面有deny相关的配置
3. 你访问的域名并没有到你访问你的这个配置文件上来,而是直接去访问了默认虚拟主机,而默认虚拟主机被限制了。

回复帖子,请先登录注册

退出全屏模式 全屏模式 回复
评分
可选评分理由: