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;
#}
}
答案1
这确实很奇怪,但我敢打赌问题在于:
try_files $uri $uri/ /index.html;
这里的问题是,这里的第二个参数导致依次尝试指令$uri/
中的每个文件。如果未找到任何文件,则继续尝试,这会导致重新输入相同的块,并且由于它仍然不存在,因此您会陷入无限循环。index
/index.html
location
我会将其重写为:
try_files $uri $uri/ =404;
如果指令中指定的索引文件均不存在,则返回 404 错误index
。
顺便说一句,您看到的请求是网络背景噪音。具体来说,它们是用于确定您的 Web 服务器是否为开放代理的探测器,当恶意用户执行恶意活动时,它们可能会被滥用来隐藏其来源。在此配置下,您的服务器不是开放代理,因此您实际上不必担心。
答案2
index.php
如果您的完全缺失,您也会收到此错误消息。
答案3
这很烦人。几个星期前它还能用,今天我试的时候却失败了。
我相信 Ubuntu 软件包的升级nginx
会导致 Ubuntu 保存标准索引文件的默认目录发生改变,因此以下行:
root /usr/share/nginx/www;
由于文件位置为,因此不再起作用/usr/share/nginx/html
。
为了解决这个问题,只需将根指针更改为正确的目录,或者创建到新目录的符号链接:
cd /usr/share/nginx
sudo ln -s html www
对我有用。
答案4
昨天我遇到了这个问题,因为我正在通过代理服务器测试 nginx,该代理服务器缓存了一个不再存在的重定向。对我来说,解决方案是在$ sudo service squid3 restart
我连接的 squid3 代理服务器上。