1. 程式人生 > >華為雲 ECS 安裝 Nginx 的埠問題

華為雲 ECS 安裝 Nginx 的埠問題

伺服器之遷徙

私人伺服器從騰訊雲遷到便宜的華為ECS,重灌系統。 裝 node , 裝 mongodb, 裝 nginx

檢測nginx 正常

nginx -t 正常

啟動nginx 服務,一切正常

service nginx start 

檢視程序 正常

ps -ef |grep nginx

瀏覽器開啟

http://ip
無法訪問

排查

伺服器 ping 外網

[email protected]:~# ping www.baidu.com
PING www.a.shifen.com (180.97.33.107) 56(84) bytes of data.
64 bytes from 180.97.33.107: icmp_seq=1 ttl=47 time=30.2 ms
64 bytes from 180.97.33.107: icmp_seq=2 ttl=47 time=29.8 ms
64 bytes from 180.97.33.107: icmp_seq=3 ttl=47 time=29.7 ms
64 bytes from 180.97.33.107: icmp_seq=4 ttl=47 time=29.7 ms
64 bytes from 180.97.33.107: icmp_seq=5 ttl=47 time=29.7 ms
64 bytes from 180.97.33.107: icmp_seq=6 ttl=47 time=29.8 ms
64 bytes from 180.97.33.107: icmp_seq=7 ttl=47 time=29.7 ms
64 bytes from 180.97.33.107: icmp_seq=8 ttl=47 time=29.7 ms

正常

ping 伺服器

PING xx.xx.xx.xx(xx.xx.xx.xx): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2
Request timeout for icmp_seq 3

curl 請求本地

root[email protected]:~# curl 127.0.0.1
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
 
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
 
<p><em>Thank you for using nginx.</em></p>
</body>
</html>

問題所在

開啟華為雲伺服器的控制檯,開啟伺服器的更改安全組> 修改安全組 > 配置規則。 將你要用的埠新增到規則中,出方向 入方向都需要新增。 在這裡插入圖片描述

在這裡插入圖片描述

打勾並新增。在這裡插入圖片描述

重啟伺服器

之前配置的服務已能正常使用。