Welcome! Log In Create A New Profile

Advanced

Route subdomains to different node instance ports on localhost (EC2)

Posted by RigidWig 
Route subdomains to different node instance ports on localhost (EC2)
January 19, 2013 02:33PM
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
Re: Route subdomains to different node instance ports on localhost (EC2)
January 20, 2013 04:55PM
Turns out I didn't consider the fact that this is impossible without a DNS server.
I thought it could be done with the IP alone.

Thanks, community
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 281
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready