系统相关
首页 > 系统相关> > nginx – 外部http连接失败(端口打开)

nginx – 外部http连接失败(端口打开)

作者:互联网

在托管的Ubuntu VM上,我运行了http和https的nginx,并且可以从VM中访问使用公共IP的那些:

curl http://159.203.0.5

在VM外部执行相同操作失败 – 连接超时.

端口是开放的:

root@production01:~# 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正在侦听外部接口:

root@production01:~# 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

还有什么呢?

解决方法:

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

看看这个:

foo@bar:~$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对我来说没问题.

标签:nginx,ip,server,cloud-hosting,digital-ocean
来源: https://codeday.me/bug/20190711/1432192.html