node.jsexpressnginxalibaba-cloud-ecs

Where can I view the local website hosted on ECS (Alibaba)?


I have created a small express app on Alibaba ECS.

Let's say that my private IP address is 121.22.15.111 and my public IP address is 50.45.23.22 (these are imaginary values).

The code is as follows:

const express = require('express');
const app = express();

app.get('/', (req, res) => {
    res.send('Hello World');
})

app.listen(8080, '121.22.15.111');

and my Nginx setup is as follows:

server {
    listen 80;
    server_name http://50.45.23.22;
    location / {
        proxy_pass http://121.22.15.111:8080;
        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;
    }
}

and then when I open http://50.45.23.22 (public IP), it shows connection timeout.

Where am I going wrong?

P.S. I don't have a domain name, rather I want to access my app through the IP address. How do I do so?


Solution

  • Just Check the security group settings of your ECS instance and allow connection from port 80 and any other which you are using in your app. It will work.