Web サーバーに繋がらないと思ったら iptables のせいでした。
RedHat Enterprise のネットワーク設定に詰まったのでメモ。
Apache 等のプロセスは立ち上げたのに、アクセスできない。
アクセスログも残ってない。
[ローカル]$ telnet xxx.xxx.xxx.xxx Trying xxx.xxx.xxx.xxx... telnet: connect to address xxx.xxx.xxx.xxx: Connection refused telnet: Unable to connect to remote host
サーバーにログインして、自分でアクセスしたらちゃんと応答が返る
[サーバー]$ telnet localhost 80 GET / HTTP/1.1 (略 ちゃんと応答が帰ってる)
なので Apache はちゃんと動いてるっぽい。
ネットワークに問題が?
パケットを監視してみる
[サーバー]# tcpdump port 80 tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes xxxxxxxxx > xxxxxxxxx.http: S xxxxxx:xxxxxx(0) win xxxxx <mss xxxx,nop,wscale 3,nop,nop,timestamp 257328529 0,sackOK,eol>
一行だけでも出力はしているので、パケットはとりあえず到着していると判断。
ここでネットワーク途中のFWではなく、サーバー内のFWを疑う。
[サーバー]# vi /etc/sysconfig/iptables 追記 -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT
[サーバー]# /etc/init.d/iptables restart [サーバー]# /sbin/iptables -L ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:http ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:https
http と https が ACCEPT になり、外からのアクセスも成功した。
たまにやる、慣れないディストリビューションの初期設定は地雷 orz