問題描述
開啟并配置iptables后,發(fā)現(xiàn)NGINX服務(wù)訪問不了了拄衰。查看NGINX日志報(bào)錯(cuò)連接超時(shí)垒拢,將防火墻策略清除后又可以正常訪問了童漩。selinux正確的配置了http端口。所以問題就出在防火墻策略上了沟蔑。
未解決前的防火墻策略
[root@Rshine ~]# iptables -vnL
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
1400 119K ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:6722
55 6151 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:80
283 28599 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:8443
76 4600 DROP all -- * * 0.0.0.0/0 0.0.0.0/0
我的NGINX監(jiān)聽的端口是8443端口湿诊,這里明明已經(jīng)開放了8443端口,但是還是無法訪問溉贿。
解決問題后的防火墻策略
[root@Rshine ~]# iptables -vnL
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
24 26944 ACCEPT all -- * * 127.0.0.1 0.0.0.0/0
1400 119K ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:6722
55 6151 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:80
283 28599 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:8443
76 4600 DROP all -- * * 0.0.0.0/0 0.0.0.0/0
就增加了一條策略枫吧,就恢復(fù)正常訪問了。
iptables -I INPUT -s 127.0.0.1 -j ACCEPT # 允許來自源地址127.0.0.1的訪問
原因是我的nginx配置了"fastcgi_pass 127.0.0.1:9000;"最后一條規(guī)則阻止了來自127.0.0.1的訪問宇色。