我剛剛創建了一個 ubuntu 16.04 的新實例。剛剛安裝了 NGINX,這就是我在netstat -ntlp
root@ip-172-31-8-234:/home/ubuntu# netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 11856/nginx -g daem
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1328/sshd
tcp6 0 0 :::80 :::* LISTEN 11856/nginx -g daem
tcp6 0 0 :::22 :::* LISTEN 1328/sshd
如果我問一個curl localhost,我會得到:
ubuntu@ip-172-31-8-234:~$ curl localhost
<!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>
這是歡迎 NGINX 頁面。至此,NGINX 似乎已經完成了。
但我希望能夠透過網路看到這個頁面。
這是我的 AWS 服務頁面中的內容。
Public DNS (IPv4) - ec2-54-94-152-233.sa-east-1.compute.amazonaws.com
Instance state - running
IPv4 Public IP - 54.94.152.233
所以我想如果我在任何瀏覽器中輸入 54.94.152.233 ,我應該可以看到歡迎頁面。
相反,我收到此錯誤訊息:
This site can’t be reached
54.94.152.233 took too long to respond.
我缺什麼?
答案1
據我所知,預設的 VPC 和安全群組設定不允許任何連接埠上的任何傳入流量。更改設定以允許連接埠 80 上的傳入流量,您應該可以了