Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure nginx to make ssh server via subdomain.domain.tld:80 available

I want to make the ssh server on port 22 available through a subdomain on port 80.

I thought it should by something like this:

server {
    listen          ssh.domain.tld:80;
    server_name     ssh.domain.tld;

    location / {
        proxy_pass          http://localhost:22;
    }
}

But it won't work. nginx will accept this and start with this configuration, but I only get empty responses from ssh.domain.tld:80.

What am I missing?

like image 850
xaedes Avatar asked Feb 04 '13 22:02

xaedes


2 Answers

Since Nginx Version 1.9.0,NGINX support ngx_stream_core_module module, it should be enabled with the --with-stream. When stream module is enable they are possible to ssh protocol tcp proxy

stream {
upstream ssh {
    server localhost:22;
}
    server {
    listen        80;
    proxy_pass    ssh;
} }

https://www.nginx.com/resources/admin-guide/tcp-load-balancing/

like image 118
Hendi Fauzi Avatar answered Nov 17 '22 05:11

Hendi Fauzi


You should use sslh.

Configure nginx to run on a different port than 80, say 800, and then configure sslh to redirect web traffic to that port in /etc/default/sslh.conf file.

This setup may take 15 min. or less.

like image 36
ceremcem Avatar answered Nov 17 '22 04:11

ceremcem