Very new to this so I'll try to be as detailed as I can be.
So the setup is like this:
An EC2 instance running ubunttu server, nginx, and node with an elastic ip, let's say ip = 54.235.215.242
I managed to get nginx listening on 80 to proxy_pass into a node instance on port 8800.
I can hit the IP (54.235.215.242) remotely in a web browser and everything works fine.
However, I have another node instance listening on port 2222, and I'd like to route to this instance from a sub domain, so that remotely:
sub.54.235.215.242 would take me to the node instance on 2222.
I've read quite a lot of examples and guides to doing this using:
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://localhost:8800;
}
}
server {
listen 80;
server_name sub.localhost;
location / {
proxy_pass http://localhost:2222;
}
}
and editing my hosts file to include the subdomain.
It does work locally, and when I "curl sub.localhost" I do get the "Hello world" return from the 2222 instance.
However, this does not work remotely (browser to sub.54.235.215.242).
How can I get this to work remotely? And is this the ideal way to do subdomains, or is there something I can read up on that is cleaner/easier to implement?
Thanks