大网数据广告活动
网站运营与故障问答

Connect timeout from external clients?

· 52CE 我爱测

I had a MEAN site hosted on DigitalOcean, and now I moved it to an EC2 micro instance. I imported the database, set up PM2, copied all files and everything, and set up Nginx as a reverse proxy. No biggie. When I "curl localhost",…

问题原文

原帖链接 · Tobe Osakwe · CC BY-SA 3.0

I had a MEAN site hosted on DigitalOcean, and now I moved it to an EC2 micro instance. I imported the database, set up PM2, copied all files and everything, and set up Nginx as a reverse proxy. No biggie.

When I "curl localhost", the site loads perfectly. But I can't connect to it from anywhere except localhost. For example, running "curl " on the old VPS gives a "connection timed out" error. And when I try to access the site in Chrome, it loads until a timeout error as well.

As you can imagine, I am confused. The following is my /etc/nginx/sites-available/default:

server {
    listen 80;
    server_name www.my-domain.com my-domain.com;
    return 301 https://$server_name$request_uri;
}

server {
  listen 443 default_server;
  ssl on;

  server_name  my-domain.com;
  ssl_certificate /etc/nginx/ssl/nginx.crt;
  ssl_certificate_key /etc/nginx/ssl/nginx.key;

  location / {
    proxy_pass http://localhost:3000;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
  }

}

Is there something I am missing here? Thanks again, just very new to AWS, and a bit confused.

已采纳解答

原帖链接 · Tobe Osakwe · CC BY-SA 3.0

Found the answer.

On an EC2 instance, ensure the following:

  • Nginx is on, and whatever server_name you're using will allow you to access it.
  • If your server has UFW on, then make sure incoming TCP connections are allowed (on ports 80 and 443)
  • Lastly, go to "edit inbound rules" in your instance's security group, and allow incoming connections via 80 and 443.

Good to go!

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2016-06-17)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。