一般情况下 nginx
是代理七层的 http
协议,其实 nginx
也可以代理第四层协议
修改配置
1 2 3 4 5 6 7 8 9 10
| http {} stream { upstream ssh-proxy { server 192.168.2.240:22; } server { listen 50022; proxy_pass ssh-proxy; } }
|
连接命令
1 2
| ssh root@192.168.7.173 -p 50022 ssh 192.168.7.173 -l root -p 50022
|
附
转发请求头
1 2 3 4 5 6 7
| location /prod-api/ { proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass xxx; }
|
本文地址: https://github.com/maxzhao-it/blog/post/605d48da/