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;
}
}
nginx
is acting as ahttp
proxy. If you set it to reverse proxy port 22 it won't allow you to pass SSH traffic - onlyhttp
traffic to the SSH server, which will obviously fail.