403禁止在使用nginx的wordpress索引上使用,其余页面工作正常

403禁止在使用nginx的wordpress索引上使用,其余页面工作正常,wordpress,nginx,http-status-code-403,Wordpress,Nginx,Http Status Code 403,我正在一个新的EC2实例上设置我的博客,因为当前托管它的服务器上的一个站点被DDoS攻击。 我在使用nginx时遇到了一些问题,因为我可以在索引上看到所有页面,但没有403,或者在页面上看到索引,但没有404(取决于我使用的配置) 这是我的nginx配置: server { listen 80; server_name www.test.com; server_name test.com; root /www/blog; include

我正在一个新的EC2实例上设置我的博客,因为当前托管它的服务器上的一个站点被DDoS攻击。 我在使用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_文件$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
有什么明显的我做错了吗


谢谢

您似乎不允许将参数发送到CMS,因此这将不会显示此URI,该URI将从数据库中获取信息并将您重定向到403页。

看起来我需要服务器{}定义中的inded index.php,而不是位置{}

添加
index.php
在服务器块中,如果不起作用,则需要删除
$uri/
,因为您不想对
执行
自动索引


编辑:刚刚注意到您已经解决了问题,因此我将添加其背后的原因,即您需要
自动索引的原因
是因为如果没有它,nginx将遵循
try\u文件
规则

  • 检查是否有名为
    /
    的文件,当然它会失败
  • 检查是否有名为
    /
    的目录(通过添加root,它将=
    /www/blog/
    ),此检查将成功,因此它将尝试列出文件夹的内容
  • 因为您没有在上指定
    autoindex
    
  • 该站点的其余部分工作正常,因为它未通过
    $uri/
    测试或无法访问,因为您可能没有名为
    image.jpg
    stylesheet.css
    等的文件夹

  • 我不知道你的意思,我正在通过?$args?lol发送论点,我回答后才意识到你已经回答了,没有注意到,我想我会编辑我的答案来解释原因。