使用背景使用stream模块转发应用服务器sftp连接请求

1.解压nginx压缩包
tar -zxvf nginx-1.16.1.tar.gz

2.指定配置项,–prefix表示安装路径,–withstream表示添加模块
./configureprefix=/usr/local/nginxmystream/nginx1.16 –withstream –with-http_stub_status_module –with-http_ssl_module

3.编译
make

4.安装
make install

5.添加模块,与http模块同级
stream {
        upstream sftp_zj {
                hash $remote_addr consistent;
                server hz-sftp1.zj.com:2122 max_fails=3 fail_timeout=60s;
                #sftp服务器端口
        }
        #sftp代理
        server {
                listen 2122;
                proxy_connect_timeout 10s;
                proxy_timeout 10s;
                proxy_pass sftp_zj;
        }
}

6.启动nginx
./nginxc /usr/local/nginxmystream/nginx1.16/conf/nginx.conf

7.完成后可删除压缩包源文件

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注