问题原文
原帖链接 · 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!
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
