nginx配置stream模块

本文详细介绍了如何通过`stream`模块在Nginx中配置SFTP代理,包括解压安装、指定参数、编译安装、配置upstream和server块,以及启动和清理步骤。

开发板推荐:天空星STM32F407VET6开发板

超高性价比 STM32主控 | 超高主频 | 一板兼容百芯 | 比赛神器 | 沉金彩色丝印

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

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

2.指定配置项,--prefix表示安装路径,--with-stream表示添加流模块
./configure --prefix=/home/app/nginx/nginx1.28.3 --with-stream --with-http_stub_status_module --add-module=/home/app/nginx/nginx-module-vts-0.2.5 --with-http_ssl_module --with-http_v2_module

--with-stream 流式请求如ftp

--with-http_stub_status_module  nginx状态监控
--with-nginx-module-vts    监控加强如上游upstream(第三方包需要先下载)

--with-http_ssl_module 支持https
--with-http_v2_module 支持http2

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
./nginx -c /home/app/nginx/nginx1.28.3/conf/nginx.conf

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

开发板推荐:天空星STM32F407VET6开发板

超高性价比 STM32主控 | 超高主频 | 一板兼容百芯 | 比赛神器 | 沉金彩色丝印

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值