问题
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?
回答1:
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/
回答2:
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.
回答3:
basically you're looking in the wrong place:
- stock nginx can proxy web and/or email traffic, it doesn't handle ssh traffic at all
- the subdomain is a dns isue: configure it in your dns settings, you need an
A
and/orAAAA
record linkingssh.domain.tld
to your ssh server'sip-adres
- the port your ssh server listens on is a ssh server setting (see
man sshd_config
specifically theListenAddress
andPort
directives)
来源:https://stackoverflow.com/questions/14696460/how-to-configure-nginx-to-make-ssh-server-via-subdomain-domain-tld80-available