Alb*_*lla 7 wordpress nginx http-status-code-403
我正在一个新的EC2实例上设置我的博客,因为当前托管它的服务器上的一个站点是DDoSed.我在使用nginx时遇到了一些麻烦,因为我可以看到所有页面都很好但索引上有403,或者看到索引但页面上有404(取决于我使用的配置)
这是我的nginx配置:
server {
listen 80;
server_name www.test.com;
server_name test.com;
root /www/blog;
include conf.d/wordpress/simple.conf;
}
Run Code Online (Sandbox Code Playgroud)
而simple.conf:
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
# This is cool because no php is touched for static content.
# include the "?$args" part so non-default permalinks doesn't break when using query string
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
include fastcgi.conf;
fastcgi_intercept_errors on;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
Run Code Online (Sandbox Code Playgroud)
如果我改变了try_files $ uri $ uri//index.php?$args; 索引index.php,首页将正常工作,其余的将是404.如果我这样离开,首页是403.
这是错误日志:
2013/08/07 19:19:41 [error] 25333#0: *1 directory index of "/www/blog/" is forbidden, client: 64.129.X.X, server: test.com, request: "GET / HTTP/1.1", host: "www.test.com"
Run Code Online (Sandbox Code Playgroud)
该目录在nginx用户上是755:
drwxr-xr-x 6 nginx nginx 4096 Aug 7 18:42 blog
Run Code Online (Sandbox Code Playgroud)
有什么明显的我做错了吗?
谢谢 !
Moh*_*ady 19
添加index index.php;在服务器块中,如果它不起作用,那么您需要删除它,$uri/因为您不想这样做autoindex on
autoindex on;是因为没有它nginx将遵循try_files规则,
/,当然它失败了./(通过添加root它将= /www/blog/),此检查将成功,因此它会尝试列出该文件夹的内容.autoindex on;,默认情况下nginx应该禁止目录列表,因此它将返回403禁止错误.$uri/测试或未到达,因为您可能没有名为image.jpg或stylesheet.css等的文件夹.| 归档时间: |
|
| 查看次数: |
17141 次 |
| 最近记录: |