LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 01-28-2014, 10:06 AM   #1
devent
LQ Newbie
 
Registered: Jan 2014
Posts: 5

Rep: Reputation: Disabled
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/
 
Old 01-28-2014, 12:45 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
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?
 
Old 01-28-2014, 12:55 PM   #3
devent
LQ Newbie
 
Registered: Jan 2014
Posts: 5

Original Poster
Rep: Reputation: Disabled
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.
 
Old 01-28-2014, 05:02 PM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by devent View Post
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
 
Old 01-29-2014, 06:37 AM   #5
devent
LQ Newbie
 
Registered: Jan 2014
Posts: 5

Original Poster
Rep: Reputation: Disabled
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.
 
Old 01-29-2014, 05:38 PM   #6
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Shouldn't that be
Code:
curl -H 'Host: www.mueller-public.de' http://localhost:2110/
 
Old 01-30-2014, 06:17 AM   #7
devent
LQ Newbie
 
Registered: Jan 2014
Posts: 5

Original Poster
Rep: Reputation: Disabled
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.
 
Old 01-30-2014, 06:46 AM   #8
devent
LQ Newbie
 
Registered: Jan 2014
Posts: 5

Original Poster
Rep: Reputation: Disabled
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
SSH tunnel proxy in Akonadi/Kontact/KMail desade Linux - Networking 5 01-18-2017 08:55 AM
Connect to a proxy through a middle host with a ssh tunnel iacchi Linux - Networking 3 02-16-2012 12:02 PM
2 linux boxes, proxy and ssh tunnel forwarding eddsstudio Linux - Newbie 3 05-25-2011 07:18 AM
How do I set up an ssh tunnel through a http proxy? wilko Linux - Networking 2 03-10-2010 01:05 PM
Web service and reverse proxy with the speedy nginx jeremy LQ Articles Discussion 0 02-23-2010 04:42 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 12:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration