LinuxQuestions.org
Register a domain and help support LQ
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
 
LinkBack Search this Thread
Old 01-09-2012, 10:00 PM   #1
haxwithaxe
LQ Newbie
 
Registered: Sep 2011
Posts: 11

Rep: Reputation: Disabled
ssh over http using nginx


I'm trying to setup a ssh over http connection using nginx as the webserver. There don't appear to be any working examples around. proxytunnel is what i'm using for the http wrapper on ssh and it doesn't seem to play well with nginx so far. It's returns:
Code:
laptop ~$ proxytunnel -v -p ssh.example.com:80 -d localhost:22 -H "User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows NT 5.1; .NET CLR 1.1.4322)\n"
Local proxy ssh.example.com resolves to 1.2.3.4
Connected to ssh.example.com:80 (local proxy)

Tunneling to localhost:22 (destination)
Communication with local proxy:
-> CONNECT localhost:60022 HTTP/1.0
-> Proxy-Connection: Keep-Alive
-> User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows NT 5.1; .NET CLR 1.1.4322)\n
<- <html>
<- <head><title>400 Bad Request</title></head>
<- <body bgcolor="white">
<- <center><h1>400 Bad Request</h1></center>
<- <hr><center>nginx/0.7.67</center>
<- </body>
<- </html>
analyze_HTTP: readline failed: Connection closed by remote host
using ssh just adds: `ssh_exchange_identification: Connection closed by remote host`

My config is as follows.
nginx:

~default: nginx.conf

sshtunnel (nginx config for the tunnel):
Code:
upstream tunnel {
   server localhost:22;
}
server {
   listen 80;
   server_name ssh.*;
   location / {
      proxy_pass http://tunnel;
      proxy_set_header Host $host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_redirect off;
   }
}
ssh:
default+gatewayports=yes+key auth only

Anyone have any ideas about what is wrong? My googlefu is failing me on this one :/
 
Old 01-11-2012, 10:42 AM   #2
cbtshare
Member
 
Registered: Jul 2009
Posts: 561

Rep: Reputation: 42
what do nginx logs say?
 
Old 01-11-2012, 10:06 PM   #3
haxwithaxe
LQ Newbie
 
Registered: Sep 2011
Posts: 11

Original Poster
Rep: Reputation: Disabled
when i was fiddling with this the day of my last post there wasn't anything in the nginx logs apart from the stuff from my browser when i was fiddling around. <strike>when i looked just now there were a couple lines for every attempt i made just now to connect to the proxy with proxytunnel.</strike> the timestamps on the nginx error log entries are from before my testing again.

/var/log/nginx/error.log
Code:
2012/01/11 23:20:50 [error] 19577#0: *5315 upstream sent no valid HTTP/1.0 header while reading response header from upstream, client: 96.231.30.41, server: ssh.*, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:22/", host: "ssh.example.com"

2012/01/11 23:20:50 [error] 19577#0: *5315 readv() failed (104: Connection reset by peer) while reading upstream, client: 96.231.30.41, server: ssh.*, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:22/", host: "ssh.example.com"
also i forgot to add the ssh config for the proxy (from .ssh/config):
Code:
Host sshtun
        DynamicForward 2280
        HostName ssh.example.com
        ProxyCommand proxytunnel -v -p ssh.example.com:80 -d localhost:22 -H "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Win32)\n"
        ServerAliveInterval 60
        IdentityFile ~/.ssh/sshtun_rsa

Last edited by haxwithaxe; 01-11-2012 at 10:43 PM. Reason: correction
 
  


Reply

Tags
nginx, ssh


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Basic HTTP Authentication With Nginx LXer Syndicated Linux News 0 09-16-2011 01:30 PM
LXer: The Core HTTP Module in Nginx LXer Syndicated Linux News 0 07-11-2011 11:41 AM
nginx, view files in a folder via http malayo Debian 3 02-14-2011 07:18 AM
LXer: How To Install A Complete LEMP (Linux - EngineX (Nginx HTTP SERVER) - Mysql - P LXer Syndicated Linux News 0 10-19-2007 08:00 PM
LXer: Nginx HTTP Server + PHP5 (With fast-cgi And xcache) On Ubuntu Feisty Fawn LXer Syndicated Linux News 0 10-10-2007 06:30 PM


All times are GMT -5. The time now is 10:45 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration