2012-02-05 130 views
8

我的服务器重定向有问题http://www.mylesgray.com:8080/ - >http://www.mylesgray.com/是什么导致这301重定向?

这里是我的Nginx defaultfastcgi_params配置文件:

https://gist.github.com/1745271

https://gist.github.com/1745313

这是相当因为我试图运行Nginx的基准W /缓存 VS 一个nusance使用Nginx顶部的清漆进行清漆,查看是否有任何性能优势。

因此我直Nginx的W /缓存侦听端口8080和端口80清漆转发上localhost:8080任何非缓存请求,Nginx的,所以很明显我想要做的是http://www.mylesgray.com:8080/和运行ab基准http://www.mylesgray.com/看到区别。

以下是各种地址的curl -I的结果。

# curl -I http://www.mylesgray.com:8080 

HTTP/1.1 301 Moved Permanently 
Server: nginx/0.7.65 
Date: Sun, 05 Feb 2012 12:07:34 GMT 
Content-Type: text/html; charset=UTF-8 
Connection: keep-alive 
X-Powered-By: PHP/5.3.2-1ubuntu4.7ppa5~lucid1 
X-Pingback: http://www.mylesgray.com/xmlrpc.php 
Location: http://www.mylesgray.com/ 

# curl -I http://mylesgray.com 

HTTP/1.1 301 Moved Permanently 
Server: nginx/0.7.65 
Content-Type: text/html; charset=UTF-8 
X-Powered-By: PHP/5.3.2-1ubuntu4.7ppa5~lucid1 
X-Pingback: http://www.mylesgray.com/xmlrpc.php 
Location: http://www.mylesgray.com/ 
Content-Length: 0 
Date: Sun, 05 Feb 2012 12:15:51 GMT 
X-Varnish: 1419774165 1419774163 
Age: 15 
Via: 1.1 varnish 
Connection: keep-alive 

# curl -I http://mylesgray.com:8080 

HTTP/1.1 301 Moved Permanently 
Server: nginx/0.7.65 
Date: Sun, 05 Feb 2012 12:16:08 GMT 
Content-Type: text/html; charset=UTF-8 
Connection: keep-alive 
X-Powered-By: PHP/5.3.2-1ubuntu4.7ppa5~lucid1 
X-Pingback: http://www.mylesgray.com/xmlrpc.php 
Location: http://www.mylesgray.com/ 

然后运行curl -I http://www.mylesgray.com给出:

# curl -I http://www.mylesgray.com 

HTTP/1.1 200 OK 
Server: nginx/0.7.65 
Content-Type: text/html; charset=UTF-8 
X-Powered-By: PHP/5.3.2-1ubuntu4.7ppa5~lucid1 
X-Pingback: http://www.mylesgray.com/xmlrpc.php 
Content-Length: 5132 
Date: Sun, 05 Feb 2012 12:07:29 GMT 
X-Varnish: 1419774133 1419774124 
Age: 30 
Via: 1.1 varnish 
Connection: keep-alive 

因此,大家可以看到80由清漆和8080送达Nginx的,但我不能找到任何地方什么,做了301重定向,而不是在nginx.conf或在sites-enabled/default文件中,我不相信它是由Wordpress本身引起的,但是非常容易修正。

请帮忙,这让我疯狂!

迈尔斯

回答

2

的X供电-通过的存在:PHP头意味着WordPress是发出301这是由于wordpress的强迫www.mylesgray.com。当您使用非标准端口时,用户代理通常会将端口包含在Host:标头中。尝试添加

fastcgi_param HTTP_HOST $host; 

与fastcgi_param指令的其余部分(或与您的考勤记录“包括fastcgi_params;”),它应该解决这个问题。

+0

我已经加入这个我'的/ etc/nginx的/ fastcgi_params'并重新启动所有服务,但卷曲仍表现出不同的'HTTP 301的所有:// www.mylesgray.com'。 – 2012-02-05 12:35:46

+0

这是我的'默认'网站conf和我的'fastcgi_params'文件分别是:https://gist.github.com/1745271和https://gist.github.com/1745313 – 2012-02-05 12:41:15

+0

您运行的是哪个版本的nginx?看来,覆盖fastcgi_param的请求头直到0.8.40才被添加。 – kolbyjack 2012-02-06 12:27:01

8

您应该在网址末尾添加“/”。此外,如果您运行ab http://foo.com,它将返回“ab:invalid URL”错误。如果你做“ab -t 10 http://example.com/”,一切都会正常工作。您应该始终在您的网址中使用'/',否则您的网络服务器将尝试自动将页面重定向到主页,这会在服务器上产生不希望的额外负载,并在网络上产生一些额外的字节。

你的Web服务器告诉你它的所作所为:

'/' 被失踪,事情是不正确与端口NUMER

# curl -I http://www.mylesgray.com:8080 
HTTP/1.1 301 Moved Permanently 
[...] 
======> Location: http://www.mylesgray.com/ 

'WWW' 和 '/' 缺失

# curl -I http://mylesgray.com 
HTTP/1.1 301 Moved Permanently 
[...] 
=======> Location: http://www.mylesgray.com/ 
[...] 

'/' 和 'WWW' 缺失

# curl -I http://mylesgray.com:8080 
HTTP/1.1 301 Moved Permanently 
[...] 
========> Location: http://www.mylesgray.com/ 

“希望帮助:)