次奥,这个必须要记一下……关于nginx错误110: Connection timed out

一下午啊一下午!!!

找尽原因!!!

nginx和php装好,配置好,各种优化,完成之后,网站就是无法打开,怎样调试,怎么访问都是无响应,都是报499错误

access.log

x.x.x.x - - [11/Nov/2012:14:55:57 +0400] "GET / HTTP/1.1" 499 0 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"

error.log

2012/11/11 15:07:46 [info] 20091#0: *74 client prematurely closed connection while reading client request line, client: x.x.x.x, server: localhost
2012/11/11 15:07:56 [info] 20091#0: *76 client prematurely closed connection while reading client request line, client: x.x.x.x, server: localhost

最后还重新编译的nginx,加上了debug,几次重试之后,发现error.log里有这么一句:

2012/11/11 15:04:32 [error] 20091#0: *69 connect() failed (110: Connection timed out) while connecting to upstream, client: x.x.x.x, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "x.x.x.x"

注意那个Connection time out,光看这,你可能会直接去查php-fpm的日志,你会发现什么都没有,一切正常,但是就是连不上9000端口,但我一直觉得是php或者nginx的问题,又将平台转移到本地(前面是我买的vps)虚拟机,将配置文件导入,打开,一切ok啊……

直接说了吧,最后以关键字Connection time out在Google查了一下,“http://houwenhui.gotoip2.com/archives/1621” 看了这哥们儿的blog,才恍然大悟……

其实是iptables的问题,我用的ubuntu平台,没有iptable的默认策略,后来我自己加的策略,也都只是针对外网的,启动之后,本机内的环回借口通讯被阻挡了,但是本地的centos就不同,因为有默认的策略,本身就有这条,行了,这一下午也没白费……最后在iptables加入:

iptables -A INPUT -i lo -j ACCEPT 

一切搞定……