在nginx中获取403禁止

时间:2018-09-12 07:47:05

标签: nginx nginx-location nginx-reverse-proxy nginx-config

我是新的nginx,并且我已经使用nginx配置了域,现在问题是域example.com出现403禁止错误,但能够访问example.com/index.html

这是我的配置

server {
    listen 80;
    root /var/www/example;
    index index.html index.php;

    server_name     example.com;

    access_log /var/log/nginx/example_access.log;
    error_log /var/log/nginx/example_error.log;


        location / {

                try_files $uri /index.html /index.php?$args;
                #try_files $uri $uri/ =404;
        }

        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
                 }

}

错误日志中出现以下错误

* 1禁止使用目录索引“ / var / www / example /” 该目录的用户和所有者为www:data及其777权限,但仍获取403。

请帮助。

0 个答案:

没有答案