Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have installed a local web server for an web application for a customer. Their server is behind NAT and uses proxy for access internet.

Is there a way to access the web application remotely from my computer?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

You will need to either create a port forwarding on the NAT router, but beware because then its open to the whole internet, or you need to have something connecting out to allow you in.

For example one thing what i like to do is to submit the following command behind a NAT.

ssh -R 10022:127.0.0.1:22 me@myserver.com

This command connects to myserver.com and opens port 10022 there. Then everything that connects to it's port 10022 will be tunneled to the source hosts 127.0.0.1:22. Later I connect to myserver.com from anywhere, and on myserver.com I submit this:

ssh -p 10022 127.0.0.1

Like this I can get behind the NAT.

You could also do the same by directly forwarding to the webserver, like this:

ssh -R 10080:<private webserver ip>:80 me@myserver.com

Now, on myserver.com, you could browse to 127.0.0.1:10080 and would get to the webserver which is behind the NAT.

Both solutions, port forwarding or SSH are working, but SSH is much more safe because you don't need to expose your private webserver to the internet.

share|improve this answer
    
Sometimes I did have the issue that my SSH connections were timing out, so I couldn't connect behind the NAT anymore. To prevent that they time out, I also often submit this inside: while [ 1 ]; do echo "1"; sleep 60; done simply to make them have a little traffic –  mauro.stettler Feb 18 '13 at 11:03
1  
alternatively you can stick ServerAliveInterval 60 in your SSH config (~/.ssh/config) and it'll do that for you. –  Oli Feb 18 '13 at 12:46
    
Nice one, thanks! –  mauro.stettler Feb 18 '13 at 12:48
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.