nginx实现四层端口转发

本背景是实现服务器代理登录

安装依赖 yum install gcc gcc-c++ zlib-devel pcre-devel openssl openssl-devel -y

重新编译nginx

./configure --prefix=/home/deploy/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-file-aio --with-stream

在http{}之外配置以下文件

stream {
        upstream tcp_proxy {
        hash $remote_addr consistent;  #远程地址做个hash
        server IP地址:22;
        }

   server {
        listen       2234;
        proxy_connect_timeout 1s;
        #proxy_timeout 10s;  #后端连接超时时间
        proxy_pass tcp_proxy;
   }
}

最后在xshell上实现远程:ssh://centos@IP地址:2235

发布了161 篇原创文章 · 获赞 69 · 访问量 25万+

猜你喜欢

转载自blog.csdn.net/baidu_38432732/article/details/103587982