我在使用firewalld的第七个。
我已经configuration了firewalld,所以443已经打开:
$ sudo firewall-cmd --zone=public --permanent --list-all public target: default icmp-block-inversion: no interfaces: sources: services: couchdb2 dhcpv6-client http https ssh ports: 443/tcp 5984/tcp protocols: masquerade: no forward-ports: sourceports: icmp-blocks: rich rules: $ sudo firewall-cmd --zone=public --add-port=443/tcp --permanent Warning: ALREADY_ENABLED: 443:tcp success
显然港口443是开放的,但…
$ curl https://127.0.0.1:443 curl: (7) Failed connect to 127.0.0.1:443; Connection refused
我也使用networking工具在http://www.yougetsignal.com/tools/open-ports/上testing它
我input我的IP地址和端口443并得到:closures端口443closures{my-ip}
有什么可能会出错? 它似乎打开,但事实并非如此。
我用这个结果查询netstat:
$ sudo netstat -lnp | grep 443 udp 0 0 127.0.0.1:323 0.0.0.0:* 443/chronyd udp6 0 0 ::1:323 :::* 443/chronyd
一旦我修复了我的nginx.conf来正确地收听443,结果如下所示:
$ sudo netstat -lnp | grep 443 tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 10197/nginx: master tcp6 0 0 :::443 :::* LISTEN 10197/nginx: master udp 0 0 127.0.0.1:323 0.0.0.0:* 443/chronyd udp6 0 0 ::1:323 :::* 443/chronyd
Connection refused错误通常意味着防火墙允许数据包通过(除非防火墙正在主动拒绝连接尝试),但没有监听目标端口号的服务。
在你的情况下,你需要确保一个HTTPs Web服务器正在运行,并且监听端口443.你可以使用下面的命令来validation。
sudo netstat -lnp | grep 443
编辑:如@Paul所示,显示的输出表示没有进程在端口443上侦听。输出是无关紧要的,因为进程ID匹配443,我们需要它与TCP协议的端口号相匹配。 您需要find类似于以下的行:
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN <pid>/<proc_name>
在添加规则之后,您需要重新加载firewalld ,或者必须重新运行命令,而不是--permanent 。
当你说--permanent firewalld只是更新configuration,但不重新加载它。