SSH over HTTP with proxytunnel and nginx

4.1k views Asked by At

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 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:

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 :/

0

There are 0 answers