Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Server
User Name
Linux - Server This forum is for the discussion of Linux Software used in a server related context.


  Search this Thread
Old 01-09-2012, 11:00 PM   #1
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:
laptop ~$ proxytunnel -v -p -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 resolves to
Connected to (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.

~default: nginx.conf

sshtunnel (nginx config for the tunnel):
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;
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, 11:42 AM   #2
Registered: Jul 2009
Posts: 619

Rep: Reputation: 42
what do nginx logs say?
Old 01-11-2012, 11:06 PM   #3
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.

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:, server: ssh.*, request: "GET / HTTP/1.1", upstream: "", host: ""

2012/01/11 23:20:50 [error] 19577#0: *5315 readv() failed (104: Connection reset by peer) while reading upstream, client:, server: ssh.*, request: "GET / HTTP/1.1", upstream: "", host: ""
also i forgot to add the ssh config for the proxy (from .ssh/config):
Host sshtun
        DynamicForward 2280
        ProxyCommand proxytunnel -v -p -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 11:43 PM. Reason: correction


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

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

All times are GMT -5. The time now is 03:21 PM.

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