Mobile app version of vmapp.org
Login or Join
Miguel251

: Connect timeout from external clients? 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,

@Miguel251

Posted in: #AmazonAws #Nginx #NodeJs

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 my-domain.com my-domain.com;
return 301 $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 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.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Miguel251

1 Comments

Sorted by latest first Latest Oldest Best

 

@Miguel251

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!

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme