LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Ssh tunnel to web site behind Nginx proxy (https://www.linuxquestions.org/questions/linux-server-73/ssh-tunnel-to-web-site-behind-nginx-proxy-4175492868/)

devent 01-28-2014 10:06 AM

Ssh tunnel to web site behind Nginx proxy
 
Hello,
I setup a web site that is using Apache and Nginx as a proxy. The web site itself runs fine. I want to access the web site with a SSH tunnel on my laptop. I can create the tunnel by:

Code:

$ ssh -v -N -p 22 www.mueller-public.de -L 2110:127.0.0.1:80
When I point Firefox to the tunnel http://localhost:2110 then I see only the default Nginx greeting page, what is to expected because the server is using name based virtual domains. So I have installed the Firefox Addon Modify Headers* to modify the Host header. As I can confirm in the access.log the correct Host header is set:

Code:

www.mueller-public.de 127.0.0.1 - - [28/Jan/2014:16:51:28 +0100] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:26.0) Gecko/20100101 Firefox/26.0" "-"
But Nginx is not showing me the www.mueller-public.de site, it still shows the default greeting page, but it should show me the www.mueller-public.de site, after all the Addon is correctly modifying the Host header. I was searching, and the Addon should me enough.

I just want to use an SSH tunnel to access the web site. Do I need to modify some different Http header?

* https://addons.mozilla.org/en-US/fir...odify-headers/

unSpawn 01-28-2014 12:45 PM

If this is for testing purposes shouldn't you just set the domain name and IP address in your /etc/hosts file? ...or phrased differently: why do you think you need SSH?

devent 01-28-2014 12:55 PM

I was trying to change my hosts file but the result is just the same. I was following the guide here:
http://stackoverflow.com/questions/1...ugh-ssh-tunnel
Also this guide that is mentioning the method of the Addon:
http://stackoverflow.com/questions/1...-remote-server
Both methods are not working. The Nginx log file is showing the correct domain but Nginx is still serving me the default page.

I was thinking for security reasons. I have multiple domains on the same server, by name based virtual hosts, but only one IP address. So I can't use SSL for each domain. Normally, I could use SSH tunnel to access admin pages so that the password is encrypted. But it doesn't work.

unSpawn 01-28-2014 05:02 PM

Quote:

Originally Posted by devent (Post 5106917)
I was trying to change my hosts file but the result is just the same.

Telling us and showing us the entry are not the same. Did you try setting it this way?
Code:

127.0.0.1 localhost www.mueller-public.de

devent 01-29-2014 06:37 AM

Hello,
I have change the hosts file to:
Quote:

127.0.0.1 localhost www.mueller-public.de
And make a SSH Tunnel:
Quote:

$ ssh -v -N -p 22 192.168.0.100 -L 2110:127.0.0.1:80
And access the site as
http://www.mueller-public.de:2110/

I get still the default Nginx page.
But why will all those methods the HTTP host is correctly "www.mueller-public.de", as shown in the logs?

Thank you for your replies.

unSpawn 01-29-2014 05:38 PM

Shouldn't that be
Code:

curl -H 'Host: www.mueller-public.de' http://localhost:2110/

devent 01-30-2014 06:17 AM

I try with curl, it's the same default Nginx page. But in access.log the Host is correctly specified as www.mueller-public.de
Code:

www.mueller-public.de 127.0.0.1 - - [30/Jan/2014:13:10:16 +0100] "GET / HTTP/1.1" 200 612 "-" "curl/7.29.0" "-"
The site is also online now. You can see that Nginx and Apache are correctly configured. It's only if I try to create SSH tunnel the proxy is not working any more and Nginx is returning the default Nginx page.

devent 01-30-2014 06:46 AM

Update:
I successful connected now to the virtual host by using
Code:

$ ssh -v -N -p 22 anr-institute.com -L 2110:www.mueller-public.de:80
And
Code:

curl -H 'Host: www.mueller-public.de' http://localhost:2110/
Is returning me the correct site. But I think it's useless because the links are all www.mueller-public.de/... and not localhost.de:2110/... Meaning if I click on any link then I go out of the SSL tunnel.


All times are GMT -5. The time now is 01:55 PM.