2014-11-23 73 views
1

我配置的Nginx网站WordPress的和我得到这个错误Nginx的配置:403禁止错误,在WordPress网站

2014/11/21 16:39:24 [error] 38741#0: *2 directory index of "/var/www/html/jurisprudencialaboral.dev/" is forbidden, client: 192.168.3.1, server: jurisprudencialaboral.dev, request: "GET/HTTP/1.1", host: "jurisprudencialaboral.dev"

这是分配给该目录的权限:

drwxr-xr-x 5 apache root 4096 Nov 21 16:28 jurisprudencialaboral.dev 

这是jurisprudencia.dev服务器内容文件:

server { 
     server_name jurisprudencialaboral.dev jurisprudencia jurisprudencialaboral; 
     root /var/www/html/jurisprudencialaboral.dev; 

     location/{ 
       try_files $uri $uri/ /index.php?q=$uri&$args; 
     } 

     error_page 404 /404.html; 

     error_page 500 502 503 504 /50x.html; 
     location = /50x.html { 
       root /usr/share/nginx/html; 
     } 

     location ~ \.php$ { 
       try_files $uri =404; 
       fastcgi_split_path_info ^(.+\.php)(/.+)$; 
       fastcgi_pass 127.0.0.1:9000; 
       #fastcgi_pass unix:/var/run/php5-fpm.sock; 
       fastcgi_index index.php; 
       include fastcgi_params; 
       #fastcgi_param SCRIPT_FILENAME /var/www/html/jurisprudencialaboral.dev$fastcgi_script_name; 
     } 

     access_log /var/log/nginx/jurisprudencialaboral.dev/access.log; 
     error_log /var/log/nginx/jurisprudencialaboral.dev/error.log; 

     location = /favicon.ico { 
       log_not_found off; 
       access_log off; 
     } 

     location = /robots.txt { 
       allow all; 
       log_not_found off; 
       access_log off; 
     } 

     # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac). 
     # Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban) 
     location ~ /\. { 
       deny all; 
     } 

     # Deny access to any files with a .php extension in the uploads directory 
     # Works in sub-directory installs and also in multisite network 
     # Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban) 
     location ~* /(?:uploads|files)/.*\.php$ { 
       deny all; 
     } 

     # Add trailing slash to */wp-admin requests. 
     rewrite /wp-admin$ $scheme://$host$uri/ permanent; 

# Directives to send expires headers and turn off 404 error logging. 
     location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ { 
       access_log off; log_not_found off; expires max; 
     } 

     # Uncomment one of the lines below for the appropriate caching plugin (if used). 
     #include global/wordpress-wp-super-cache.conf; 
     #include global/wordpress-w3-total-cache.conf; 
} 

我把它从here,我做错了什么?为什么403错误?

回答

2

这很清楚。您请求URI /,以便nginx尝试列出docroot内容,但由于autoindex指令默认值为false,因此不允许此操作,并且nginx会返回足够的HTTP 403

您忘记设置index指令来提供索引文件。

+0

谢谢,还有一个问题,为什么错误没有登录?我可以看到前一个,但新的不记录。例如,现在网站不工作,我怀疑是与DB有关的东西,但我不清楚,因为日志仍然是空的,为什么? – ReynierPM 2014-11-23 21:23:21

+0

@ReynierPM你在说什么日志? – 2014-11-23 21:24:34

+0

这个'error_log/var/log/nginx/jurisprudencialaboral.dev/error.log'这个文件只包含像这样的错误'2014/11/21 16:49:25 [error] 38741#0:* 4目录索引“/var/www/html/jurisprudencialaboral.dev/”被禁止,客户端:192.168.3.1,服务器:jurisprudencialaboral.dev,请求:“GET/HTTP/1.1”,主持人:“jurisprudencialaboral.dev”'但现在我得到一个空白页面,需要找到是什么导致了这个问题,但没有错误我怎么知道? – ReynierPM 2014-11-23 21:25:53