horizon 无法访问,This site can’t be reached

环境:

centos7.6 minimal
openstack master

问题描述:

在用devstack搭建环境后,无法访问horizon的页面,使用

systemctl status [email protected]*

查看服务,发现所有的服务都是正常的。

解决过程:

一开始以为是防火墙的缘故(过去有遇到这种情况),通过

systemctl status firewalld

发现firewalld确实起了,通过

systemctl disable firewalld

禁用firewalld后依旧无效。
查看页面的报错如图:
horizon 无法访问,This site can’t be reached

便感觉是网络原因,使用

telnet 10.211.55.8 80

发现无法建立连接,更加确定了是端口没有放开的原因
由于对iptables不了解所以学习了下,感觉这篇文章不错,对iptables不熟的可以学习下,虽然作者是以ubuntu平台作介绍的,但是大部分内容同样适用于centos。

通过

iptables -L --line-number

得到

Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination
1    ACCEPT     udp  --  anywhere             anywhere             udp dpt:domain
2    ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:domain
3    ACCEPT     udp  --  anywhere             anywhere             udp dpt:bootps
4    ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:bootps
5    ACCEPT     all  --  anywhere             anywhere             state RELATED,ESTABLISHED
6    ACCEPT     icmp --  anywhere             anywhere
7    ACCEPT     all  --  anywhere             anywhere
8    ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:ssh
9    REJECT     all  --  anywhere             anywhere             reject-with icmp-host-prohibited

Chain FORWARD (policy ACCEPT)
num  target     prot opt source               destination
1    ACCEPT     all  --  anywhere             192.168.122.0/24     ctstate RELATED,ESTABLISHED
2    ACCEPT     all  --  192.168.122.0/24     anywhere
3    ACCEPT     all  --  anywhere             anywhere
4    REJECT     all  --  anywhere             anywhere             reject-with icmp-port-unreachable
5    REJECT     all  --  anywhere             anywhere             reject-with icmp-port-unreachable
6    REJECT     all  --  anywhere             anywhere             reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination
1    ACCEPT     udp  --  anywhere             anywhere             udp dpt:bootpc

发下INPUT的chain没有开放80,而且第九条是reject所有(意味着,在第九条被命中的话就会被丢掉)
所以需要在第九规则前加一条,匹配80端口的

# 我的eth0是对外的
iptables -I INPUT 8 -i eth0 -j ACCEPT
# 保存刚才的修改
service iptables save

到这里便可以访问了
horizon 无法访问,This site can’t be reached