簡體   English   中英

為什么我在 AWS EC2 上的 Nginx 設置不起作用?

[英]Why does my setup of Nginx on AWS EC2 is not working?

我已經在 AWS EC2、Ubuntu 20.04 服務器上設置了 Nginx。 我使用了以下命令:

# add nodejs 10 ppa (personal package archive) from nodesource
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -

# install nodejs and npm
sudo apt-get install -y nodejs
# install nginx
sudo apt-get install -y nginx


echo "
----------------------
  UFW (FIREWALL)
----------------------
"
# allow ssh connections through firewall
sudo ufw allow OpenSSH
# allow http & https through firewall
sudo ufw allow 'Nginx Full'
# enable firewall
sudo ufw --force enable

另外,我打開了正確的端口,如下圖所示這個圖片

但是,我仍然無法訪問 URL http://IP_ADRESS。

可能是什么問題?

您是否確認如果您使用的是 IP,它是分配給 EC2 實例的彈性 IP 而不是私有 IP? 因為有時有些人使用私有 IP 認為他們將能夠訪問,而實際上他們應該使用為 Ec2 實例創建的 DNS。

然后,您還應該驗證您的 Ec2 實例是否在具有必要配置以將自身暴露到 Internet 的 VPC / 子網中,因為如果沒有,即使您有一個端口打開的 SG,您也將無法訪問它.

檢查用於 EC2 實例的安全組 HTTP 和 HTTPS 是否分配了端口 80-HTTP 和 443-HTTPS。

在您的 EC2 實例上安裝和配置 ngix( https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-20-04 ),此鏈接以及sudo systemctl enable nginx && sudo systemctl start nginx可能會有所幫助sudo systemctl enable nginx && sudo systemctl start nginx命令由 CherryDT 建議,可以在安裝 ngix 后執行。

When you access the assigned IPV4 check if it works with http:// in front of the IP and after you have configured the SSL ( https://medium.datadriveninvestor.com/nginx-server-ssl-setup-on-aws- ec2-linux-b6bb454e2ef2 )您可以嘗試使用https://訪問它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM