如何在Ubuntu中打开443端口?

我现在有一些问题,当我们的网站下ssl和使用443端口的工作。 我发现这个网站检查您的服务器的状态。 它说443已经closures了。

Port 443 is closed on xx.xxx.xx.xxx. 

过了一段时间,我尝试了一切,我不知道我做错了什么。

netstat显示了这一点:

 sudo netstat -anltp | grep LISTEN tcp 0 0 0.0.0.0:993 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:995 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:110 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:143 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:8081 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 

 netstat -nap | grep 443 tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 27898/nginx tcp 1 0 127.0.0.1:34371 127.0.0.1:443 CLOSE_WAIT 25998/openssl 

据说nginx正在监听那个端口,对吗?

这样看,因为如果我使用openssl客户端,我会得到:

 openssl s_client -connect 127.0.0.1:443 CONNECTED(00000003) 

但是当我尝试从外部使用443端口到达我的服务器时,连接超时。

 openssl s_client -connect xx.xx.xx.xx:443 connect: Connection timed out connect:errno=110 

这里的iptable规则

 sudo iptables -L Chain INPUT (policy ACCEPT) target prot opt source destination ACCEPT tcp -- anywhere anywhere tcp dpt:https Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination ACCEPT tcp -- anywhere anywhere tcp dpt:https Chain ufw-after-forward (0 references) target prot opt source destination Chain ufw-after-input (0 references) target prot opt source destination Chain ufw-after-logging-forward (0 references) target prot opt source destination Chain ufw-after-logging-input (0 references) target prot opt source destination Chain ufw-after-logging-output (0 references) target prot opt source destination Chain ufw-after-output (0 references) target prot opt source destination Chain ufw-before-forward (0 references) target prot opt source destination Chain ufw-before-input (0 references) target prot opt source destination Chain ufw-before-logging-forward (0 references) target prot opt source destination Chain ufw-before-logging-input (0 references) target prot opt source destination Chain ufw-before-logging-output (0 references) target prot opt source destination Chain ufw-before-output (0 references) target prot opt source destination Chain ufw-reject-forward (0 references) target prot opt source destination Chain ufw-reject-input (0 references) target prot opt source destination Chain ufw-reject-output (0 references) target prot opt source destination Chain ufw-track-input (0 references) target prot opt source destination Chain ufw-track-output (0 references) target prot opt source destination 

任何build议,将不胜感激。

谢谢。

更新:我忘了提及没有防火墙实际上运行:

 ufw status Status: inactive 

首先检查一下:

  • 你的服务器在防火墙后面吗? 由于防火墙configuration,端口可能会closures
  • 只有root用户可以绑定到端口433(和其他低端口)。 您的服务器是否以正确的权限启动? (通常将其configuration为在自己的用户下运行,但需要由root用户启动。)

PS鉴于你的编辑(nginx正在监听端口443),它看起来像是一个防火墙问题。 请注意,有两种types的防火墙:内部(在您的服务器上运行)和外部(在控制您的服务器的networking访问的另一台计算机上运行)。 您的更新只显示没有内部防火墙。