VMWareにCentosを入れて、yum でapacheを入れる。でもそれだけじゃアクセス出来ない。
CentOSのFirewall 、iptablesの設定を更新する必要がある。
まずは初期状態の確認。
[root@centos ~]# iptables -L –line-number
Chain INPUT (policy ACCEPT)
num target prot opt source destination
1 ACCEPT all — anywhere anywhere state RELATED,ESTABLISHED
2 ACCEPT icmp — anywhere anywhere
3 ACCEPT all — anywhere anywhere
4 ACCEPT tcp — anywhere anywhere state NEW tcp dpt:ssh
5 REJECT all — anywhere anywhere reject-with icmp-host-prohibitedChain FORWARD (policy ACCEPT)
num target prot opt source destination
1 REJECT all — anywhere anywhere reject-with icmp-host-prohibitedChain OUTPUT (policy ACCEPT)
num target prot opt source destination
Chain INPUTがフィルターの流れ。
4行目でsshが許可されているが、次の5行目で残りがrejectされるようになっている。
つまりこの間に、httpやhttpsといった外部からつなげたいポートを許可する設定を書くって訳だ。
# /sbin/iptables -I INPUT 5 -p tcp –dport https -j ACCEPT
# /sbin/iptables -I INPUT 5 -p tcp –dport http -j ACCEPT
確認。
[root@centos ~]# iptables -L –line-number
Chain INPUT (policy ACCEPT)
num target prot opt source destination
1 ACCEPT all — anywhere anywhere state RELATED,ESTABLISHED
2 ACCEPT icmp — anywhere anywhere
3 ACCEPT all — anywhere anywhere
4 ACCEPT tcp — anywhere anywhere state NEW tcp dpt:ssh
5 ACCEPT tcp — anywhere anywhere tcp dpt:http
6 ACCEPT tcp — anywhere anywhere tcp dpt:https
7 REJECT all — anywhere anywhere reject-with icmp-host-prohibitedChain FORWARD (policy ACCEPT)
num target prot opt source destination
1 REJECT all — anywhere anywhere reject-with icmp-host-prohibitedChain OUTPUT (policy ACCEPT)
num target prot opt source destination
よしよし。
設定を保存。
# /sbin/service iptables save
後からpostgresを許可したければ、こんな感じにすればいいのかな。
# /sbin/iptables -I INPUT 7 -p tcp –dport 5432 -j ACCEPT























