nginx开启后主机无法访问虚拟机的nginx解决方案
如果IP可以通的话 一般是防火墙引起
方法1、cat /etc/sysconfig/iptables
# Generated by iptables-save v1.4.7 on Fri Nov 18 01:51:49 2016 *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [40:3968] -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT -A INPUT -p icmp -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT -A INPUT -j REJECT --reject-with icmp-host-prohibited -A FORWARD -j REJECT --reject-with icmp-host-prohibited COMMIT
加-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
方法2、
[root@localhost ]# /sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT [root@localhost ]# /etc/init.d/iptables save [root@localhost ]# /etc/init.d/iptables restart
2