【问题标题】:Why does my setup of Nginx on AWS EC2 is not working?为什么我在 AWS EC2 上的 Nginx 设置不起作用?
【发布时间】:2021-07-01 09:28:30
【问题描述】:

我已经在 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。

可能是什么问题?

【问题讨论】:

  • 也许你还没有启用和启动 nginx? sudo systemctl enable nginx && sudo systemctl start nginx
  • 我也已经完成了这一步
  • 然后用sudo journalctl -u nginx检查nginx的输出
  • 还是不行... journalctl 没有显示任何问题

标签: node.js amazon-web-services nginx amazon-ec2


【解决方案1】:

您是否确认如果您使用的是 IP,它是分配给 EC2 实例的弹性 IP 而不是私有 IP?因为有时有些人使用私有 IP 认为他们可以访问,而实际上他们应该使用为 Ec2 实例创建的 DNS。

然后您还应该验证您的 Ec2 实例是否在具有必要配置的 VPC / 子网中以将自身暴露给互联网,因为如果不是,即使您有一个开放端口的 SG,您也无法访问它。

【讨论】:

    猜你喜欢
    • 2018-07-19
    • 2014-09-18
    • 1970-01-01
    • 2023-03-02
    • 1970-01-01
    • 2019-07-08
    • 1970-01-01
    • 2018-12-02
    • 2019-01-07
    相关资源
    最近更新 更多