标签:name keep host stream http centos 转发 hostname net
[root@centos7 nginx]# hostname -i
fe80::573d:3f45:8bb8:5050%ens33 192.168.0.11
[root@centos7 nginx]#
[root@centos7 nginx]# cat nginx.conf
worker_processes 2;
events {
worker_connections 1024;
}
stream {
upstream ssh_proxy {
hash $remote_addr consistent;
server 192.168.0.13:22;
}
server {
listen 2222;
proxy_connect_timeout 5s;
proxy_timeout 5s;
proxy_pass ssh_proxy;
}
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name www.etiantian.org;
index index.html index.htm;
location = / {
return 500;
}
}
}
[root@centos7 nginx]#
[root@centos7 nginx]# netstat -nultp|grep nginx
tcp 0 0 0.0.0.0:2222 0.0.0.0:* LISTEN 78097/nginx: master
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 78097/nginx: master
[root@centos7 nginx]#
[root@centos7 nginx]# ssh -p 2222 192.168.0.11
root@192.168.0.11‘s password:
Last login: Wed Jul 22 19:50:25 2020 from 192.168.0.1
[root@centos7 ~]#
[root@centos7 ~]# hostname -i
fe80::63aa:b68b:9d82:1610%ens33 fe80::573d:3f45:8bb8:5050%ens33 192.168.0.13
[root@centos7 ~]#
监听本机的2222端口,实现跳转到192.168.0.13的22号端口
ssh -p 2222 192.168.0.11 就会跳转到192.168.0.13
标签:name keep host stream http centos 转发 hostname net
原文地址:https://www.cnblogs.com/k8s-pod/p/13378049.html