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;
}
}
我还想代理ssh(端口22)请求。我可以将另一个服务器块添加到同一配置文件中吗:
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;
}
}
这样最终结果是这样的:
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,
奥莱
去看看HAProxy。
nginx
充当http
代理。如果将其设置为反向代理端口22,则将不允许您传递SSH流量-仅将http
流量传递到SSH服务器,这显然会失败。