2016-01-24 39 views
4

在托管Ubuntu的虚拟机,我有nginx的为httphttps运行,并且可以访问那些使用从虚拟机内的公网IP:外部HTTP连接失败(开放的端口)

curl http://159.203.0.5 

外面做同样的虚拟机发生故障 - 连接超时。

的端口是开放的:

[email protected]:~# ufw status 
Status: active 

To       Action  From 
--       ------  ---- 
22       ALLOW  Anywhere 
80       ALLOW  Anywhere 
443      ALLOW  Anywhere 
22 (v6)     ALLOW  Anywhere (v6) 
80 (v6)     ALLOW  Anywhere (v6) 
443 (v6)     ALLOW  Anywhere (v6) 

而且nginx的监听外部接口上:

[email protected]:~# netstat -an | grep "LISTEN " 
tcp  0  0 0.0.0.0:80    0.0.0.0:*    LISTEN  
tcp  0  0 0.0.0.0:2003   0.0.0.0:*    LISTEN  
tcp  0  0 0.0.0.0:2004   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:25    0.0.0.0:*    LISTEN  
tcp  0  0 0.0.0.0:443    0.0.0.0:*    LISTEN  
tcp  0  0 0.0.0.0:2812   0.0.0.0:*    LISTEN  
tcp  0  0 0.0.0.0:8002   0.0.0.0:*    LISTEN  
tcp  0  0 127.0.0.1:6379   0.0.0.0:*    LISTEN  
tcp6  0  0 :::22     :::*     LISTEN  
tcp6  0  0 :::25     :::*     LISTEN 

还能是什么呢?

+0

是的,公共IP是129.203.0.5。我可以ping通它和SSH,但http和https没有对外提供任何响应。 –

+0

入站流量可以被iptables限制,所以这是第一次检查。有时服务器上存在许多nginx二进制文件,并导致奇怪的行为。你确定它是监听的nginx(或者nginx二进制/进程)吗? netstat -tlnp | awk'/:80 */{split($ NF,a,“/”);打印[2],a [1]}'然后用“nginx -V”检查进程是否加载了正确的conf文件。在此检查后,请确保您没有配置问题(nginx.conf和/或专用配置文件)。你应该在问题中为你的配置文件添加一个链接。 –

回答

0

我认为问题不在虚拟机上,而是在您尝试连接到虚拟机的机器上。此机器上的其他连接是否正常工作?

看看这个:

[email protected]:~$ curl 159.203.0.5 -v 
* Rebuilt URL to: 159.203.0.5/ 
* Hostname was NOT found in DNS cache 
* Trying 159.203.0.5... 
* Connected to 159.203.0.5 (159.203.0.5) port 80 (#0) 
> GET/HTTP/1.1 
> User-Agent: curl/7.35.0 
> Host: 159.203.0.5 
> Accept: */* 
> 
< HTTP/1.1 404 Not Found 
< X-Powered-By: Express 
< X-Content-Type-Options: nosniff 
< Content-Type: text/html; charset=utf-8 
< Content-Length: 13 
< Date: Tue, 02 Feb 2016 17:36:31 GMT 
< Connection: keep-alive 
< 
Cannot GET/
* Connection #0 to host 159.203.0.5 left intact 

我没有得到超时,这404看起来不错我。

+0

我很抱歉,在找不到解决方案后,我在周末拿下了虚拟机。因此,知识产权现在已被重新分配给其他人。 –

相关问题