Wordpress Nginx';内部重定向时的重写或内部重定向循环';导致500人死亡

Wordpress Nginx';内部重定向时的重写或内部重定向循环';导致500人死亡,wordpress,nginx,Wordpress,Nginx,我对nginx 1.2.1-2.2治疗Raspbian哮喘病有点问题。我想这是在我更改了站点可用/默认文件中的索引之后开始的。以下是相关文件: nginx.conf user www-data; worker_processes 4; pid /var/run/nginx.pid; events { worker_connections 768; # multi_accept on; } http { ## # Basic Settings ##

我对nginx 1.2.1-2.2治疗Raspbian哮喘病有点问题。我想这是在我更改了站点可用/默认文件中的索引之后开始的。以下是相关文件:

nginx.conf
user www-data;
worker_processes 4;
pid /var/run/nginx.pid;

events {
    worker_connections 768;
    # multi_accept on;
}

http {

    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    index index.html index.htm index.php;
    # server_tokens off;

    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    ##
    # Logging Settings
    ##

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

    ##
    # Gzip Settings
    ##

    gzip on;
    gzip_disable "msie6";

    # gzip_vary on;
    # gzip_proxied any;
    # gzip_comp_level 6;
    # gzip_buffers 16 8k;
    # gzip_http_version 1.1;
    # gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

    ##
    # nginx-naxsi config
    ##
    # Uncomment it if you installed nginx-naxsi
    ##

    #include /etc/nginx/naxsi_core.rules;

    ##
    # nginx-passenger config
    ##
    # Uncomment it if you installed nginx-passenger
    ##

    #passenger_root /usr;
    #passenger_ruby /usr/bin/ruby;

    ##
    # Virtual Host Configs
    ##

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}

尝试访问任何WordPress页面时,包括在地址栏中键入local.dyn.kwl.me/WordPress/或将index.php或wp admin添加到该URL时,我都会出错。在浏览器中显示为500,但nginx日志显示:

2013/08/19 17:55:49 [error] 31600#0: *58 rewrite or internal redirection cycle while internally redirecting to "/wordpress/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html", client: 109.149.13.53, server: localhost, request: "GET /wordpress HTTP/1.1", host: "local.dyn.kwl.me"
2013/08/19 17:55:49 [error] 31600#0: *59 rewrite or internal redirection cycle while internally redirecting to "/favicon.ico/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html", client: 109.149.13.53, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "local.dyn.kwl.me"

我会想象索引或我的站点默认文件中的try_文件有问题。有人能看到什么吗?

你试过这样的东西吗?(可能针对Magento)


HTH

我经常在Nginx上运行WordPress站点。如果您可以使用位置指令,下面是位置指令的部分成功配置。Nginx版本是
1.0.15
。您可能希望更改
fastcgi\u pass
param,以运行fastcgi\u包装器运行的任何程序。可能
fastcgi\u pass 127.0.0.1:9000

    location @php { 
        try_files $uri =404;
        include /etc/nginx/fastcgi_params;
        fastcgi_pass 127.0.0.1:9090;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_intercept_errors on;
    }  

    if (!-e $request_filename){
            rewrite ^(.*)$ /index.php?q=$1 last;
            break;
    }
因此,在您的站点配置中

sites-available/default

server {
    listen   80; ## listen for ipv4; this line is default and implied
    #listen   [::]:80 default_server ipv6only=on; ## listen for ipv6

    root /home/tom/www;
    index index.html index.htm index.php;

    # Make site accessible from http://localhost/
    server_name localhost;


    # Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
    #location /RequestDenied {
    #   proxy_pass http://127.0.0.1:8080;    
    #}

    error_page 404 /404.html;

    # redirect server error pages to the static page /50x.html

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

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    ## Original Config
    # location ~ \.php$ {
    #    fastcgi_split_path_info ^(.+\.php)(/.+)$;
        # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini

        # With php5-cgi alone:
        # fastcgi_pass 127.0.0.1:9000;
        # With php5-fpm:
    #    fastcgi_pass unix:/var/run/php5-fpm.sock;
    #    fastcgi_index index.php;
    #    include fastcgi_params;
    # }

    ## New Config
    location @php { ## Depending on your Nginx version, you might need to change this to location ~ \.php$ {
      try_files $uri =404;
      include /etc/nginx/fastcgi_params;
      fastcgi_pass 127.0.0.1:9090; ## Maybe change to 9000 or use socket fastcgi_pass unix:/var/run/php5-fpm.sock;
      fastcgi_index index.php;
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      fastcgi_intercept_errors on;
    }

    ## Wordpress Rewrite
    if (!-e $request_filename){
            rewrite ^(.*)$ /index.php?q=$1 last;
            break;
    }

}
编辑

根据你上次对我的评论。如果DNS没有解析到子目录/wordpress/,则必须更改重写规则

    ## Wordpress Rewrite
    if (!-e $request_filename){
            rewrite ^(.*)$ /wordpress/index.php?q=$1 last;
            break;
    }
试试这个

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

你指的是什么位置?您是否使用domain.com/yourls访问您的Wordpress站点?为什么在位置块之外有try_文件?我在magento站点上遇到此错误too@JoeBuckle那无关紧要。WordPress存储在/WordPress/@Danack中。我的研究建议我应该尝试添加它来修复我遇到的错误。好吧,这很有效,但只是一点点。现在我得到了
2013/08/20 15:04:42[错误]591#0:*6在内部重定向到“/favicon.ico”时的重写或内部重定向周期,客户端:109.149.13.53,服务器:local.dyn.kwl.me,请求:“GET/favicon.ico HTTP/1.1”,主机:“local.dyn.kwl.me”
,因此没有所有索引内容,只是favicon.ico错误。当我遇到同样的问题时,我发现我在https根文件夹上输入了1个字符。现在WordPress(我的其他目录仍然没有任何问题)想要下载一个名为“下载”的文件,其中包含index.php的内容。我很困惑:/I我正在使用您发布的配置,使用
location~\.php$
,并使用套接字而不是php5 fpm的本地IP和端口。它正在尝试下载文件,因为您没有将请求传递给php,所以我认为您的fastcgi\u pass配置可能是错误的。如果在
unix:/var/run/php5-fpm.sock之前工作,请尝试使用此fastcgi_pass fastcgi_pass嗯,/yourls-next(php脚本)和/wordpress/wp-admin都能正常工作。只有/wordpress可以立即生成下载文件/wordpress/index.php需要一段时间,但仍然要求我下载该文件。我曾尝试禁用WordPress重写规则,但没有任何效果。我可能会尝试重新安装WordPress。配置中没有专门针对WordPress前端的内容。我认为这与WordPress的安装无关。您使用什么作为FastCGI包装器?我猜是php fpm吗?是的,来自debian存储库的php5 fpm包。我将尝试重新安装WordPress。我认为这可能与打开维护模式有关,但我现在禁用了该模式,并且没有任何变化。最好简单解释一下为什么这会对询问者有所帮助。
    ## Wordpress Rewrite
    if (!-e $request_filename){
            rewrite ^(.*)$ /wordpress/index.php?q=$1 last;
            break;
    }
location / {
...   
try_files $uri $uri/ /index.php?q=$uri&$args;
}