I have NGINX configured like this as a reverse proxy for http requests:
server {
listen 80;
server_name 203.0.113.2;
proxy_set_header X-Real-IP $remote_addr; # pass on real client IP
location / {
proxy_pass http://203.0.113.1:3000;
}
}
I also want to proxy ssh (Port 22) requests. Can I add another server block like this to the same configuration file:
server {
listen 22;
server_name 203.0.113.2;
proxy_set_header X-Real-IP $remote_addr; # pass on real client IP
location / {
proxy_pass http://203.0.113.1:22;
}
}
Such that the end result is this:
server {
listen 80;
server_name 203.0.113.2;
proxy_set_header X-Real-IP $remote_addr; # pass on real client IP
location / {
proxy_pass http://203.0.113.1:3000;
}
}
server {
listen 22;
server_name 203.0.113.2;
proxy_set_header X-Real-IP $remote_addr; # pass on real client IP
location / {
proxy_pass http://203.0.113.1:22;
}
}
TIA,
Ole
The ssh protocol is not based on HTTP, and, as such, cannot be proxied through the regular proxy_pass
of ngx_http_proxy_module
However, recently, starting with nginx 1.9.0 (released as stable with 1.10.0 on 2016-04-26), nginx did gain support for doing TCP stream proxying, which means that if you have a recent-enough version of nginx, you can, in fact, proxy ssh connections with it (however, note that you wouldn't be able to add anything like the X-Real-IP
to the proxied connection, as this is not based on HTTP).
For more information and examples, take a look at:
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments