tail -f /var/log/nginx/error.log
2013/05/04 23:43:35 [error] 733#0: *3662 rewrite or internal redirection cycle while internally redirecting to "/index.html", client: 127.0.0.1, server: _, request: "GET /robots.txt HTTP/1.1", host: "kowol.mysite.net"
HTTP/1.1", host: "www.joesfitness.net"
2013/05/05 00:49:14 [error] 733#0: *3783 rewrite or internal redirection cycle while internally redirecting to "/index.html", client: 127.0.0.1, server: _, request: "GET / http://www.qq.com/ HTTP/1.1", host: "www.qq.com"
2013/05/05 03:12:33 [error] 733#0: *4232 rewrite or internal redirection cycle while internally redirecting to "/index.html", client: 127.0.0.1, server: _, request: "GET / HTTP/1.1", host: "joesfitness.net"
我从 nginx 错误日志中获取这些信息,我没有“kowol”子域,我的网站上没有任何指向 qq.com 或 joesfitness.net 的链接。这是怎么回事?
编辑:Nginx 默认配置:
server {
listen 8080; ## listen for ipv4; this line is default and implied
listen [::]:8080 default ipv6only=on; ## listen for ipv6
root /usr/share/nginx/www;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to index.html
try_files $uri $uri/ /index.html;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
location /doc/ {
alias /usr/share/doc/;
autoindex on;
allow 127.0.0.1;
deny all;
}
# Only for nginx-naxsi : process denied requests
#location /RequestDenied {
# For example, return an error code
#return 418;
#}
#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
#
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;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
好吧,这是一个奇怪的问题,尽管我敢打赌问题在于:
这里的问题是这里的第二个参数
$uri/
,导致index
依次尝试指令中的每个文件。如果没有找到,它就会移动到,这会导致重新进入/index.html
同一个块,并且由于它仍然不存在,您将陷入无限循环。location
我会将其重写为:
index
如果您在指令中指定的索引文件都不存在,则返回 404 错误。顺便说一句,您看到的那些请求是Internet 背景噪音。特别是,它们是用于确定您的 Web 服务器是否是开放代理的探测器,并且可以被滥用以在恶意用户执行恶意活动时隐藏其来源。您的服务器在此配置中不是开放代理,因此您真的不需要担心。
index.php
如果您完全丢失,您也会收到此错误消息。这很烦人。几周前它还在工作,今天我尝试时却失败了。
nginx
我相信 Ubuntu软件包的升级会导致 Ubuntu 保存标准索引文件的默认目录发生更改,因此该行:将不再工作,因为文件的位置是
/usr/share/nginx/html
.要修复,只需将根指针更改为正确的目录,或创建指向新目录的符号链接:
为我工作。
今天有这个错误,花几个小时找出原因。原来有人删除了该网站的所有文件。
我昨天遇到了这个问题,因为我正在通过缓存了不再存在的重定向的代理服务器测试 nginx。我的解决方案是
$ sudo service squid3 restart
在我连接的 squid3 代理服务器上。只是在发生这种情况时添加另一个案例。与接受的答案一样,通常,当尝试一系列位置然后创建某种内部重定向循环(永无止境)时,就会发生这种情况。
它有时表现为错误的 NGINX 配置,甚至是限制性的 chmod(在某些锁定配置中)。这是例子。
假设你有
index.php
前端控制器,像往常一样:您主要
/some/thing
通过您的index.php
.但像往常一样,有一些 PHP 文件需要直接公开(因此
location ~\.php
不是location = /index.php
.还假设您
index.php
被chmod
-ded 到 0400 以进行安全锁定。在这种情况下一切仍然正常,只要该文件归“PHP-FPM 用户”所有。NGINX 不需要读取文件,因为它只是将文件名传递给 PHP-FPM 执行并取回 FastCGI 响应。
然后你想处理当有人访问时会发生什么的情况,
/non-existent.php
因为使用这个相当标准的配置你会得到No input file specified.
这种情况。为了解决这个问题,一些人补充说:
好吧,根据 nginx 当然
if
是邪恶的,但这不是它。现在一切都会因重定向循环错误而中断。为什么?因为这个序列发生在一个循环中:
/some/page
,nginx进入location /
,没有找到真正的文件,转为/index.php
.php
位置块并尝试检查它是否可以读取index.php
。因为它不能,所以它将它重写为相同的index.php
然后.php
再次返回。您可以尝试从 default.conf“try_files”语法中删除 index.html:
有了这个:
我意识到 nginx 正在尝试通过 index.php 解析 index.html 但在这一行上它返回到 index.html 并且它保持循环