我正在一个新的 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;
}
和 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;
}
如果我改变 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"
该目录在 nginx 用户上是 755:
drwxr-xr-x 6 nginx nginx 4096 Aug 7 18:42 blog
有什么明显的我做错了吗?
谢谢 !