andrux
andrux

Reputation: 2922

How can I access my nodejs web server from my local computer using the server domain name?

I installed nodejs and created a sample app. When I run npm start I get a message saying that I can open my web browser to http://localhost:3000 to see the app in action, but this installation is on a web server - not my local computer, so, instead of localhost:3000 I want to get there using something like mydomain.com:3000

I can't find the answer, it's very likely I just don't know how to search for it... any ideas?

I'm following the tutorial here: https://facebook.github.io/react/tutorial/tutorial.html

Upvotes: 0

Views: 339

Answers (1)

andrux
andrux

Reputation: 2922

I think I only needed to get away from this for a while. I got it working using ssh local forwarding.

I already used an ssh config file to log in to my server without having to remember the password, so I just added this line to my config file:

LocalForward localhost:3000 xxx.xxx.xxx.xxx:3000

where xxx.xxx.xxx.xxx is my server IP address.

Then, I connected to my server via ssh:

ssh -f -N mysite

Once connected, I open up the browser and go to localhost:3000 and there it is now.

I used my ssh config file, but it should also work without it.

ssh -f -N -R 3000:localhost:3000 mydomain.com

I found this command that eventually led me to solve my problem in this link: http://stuff-things.net/2016/01/20/tunneling-to-localhost/

Upvotes: 0

Related Questions