Nginx使用stream模块反代TCP端口
分类:linux日期:2020-04-07 - 11:25:15评论:1条作者:老谢
首先要确认Nginx有没有编译stream模块进去,使用nginx -V来查看,如果看到–with-stream则表示编译进去了,如果没用重新编译加入stream参数即可,配置字段要加到nginx.conf下面:
| stream { server { listen 12345; proxy_pass 1.1.1.1:1111; proxy_buffer_size 512k; proxy_connect_timeout 30s; proxy_timeout 30s; #allow 127.0.0.0/24; #deny all; } server { listen 1083; proxy_pass 2.2.2.2:1080; proxy_buffer_size 512k; proxy_connect_timeout 30s; proxy_timeout 30s; #allow 127.0.0.0/24; #deny all; } } | 
listen:后面填写源端口(也就是当前服务器端口),默认协议为TCP,可以指定为
proxy_connect_timeout:连接超时时间
proxy_timeout:超时时间
proxy_pass:填写转发目标的IP及端口号

最新评论
秦大叔:现在都是够用就好,不想太折腾了。
Andy烧麦:X1C 5th 2017年-2022年,走南闯北...
王叨叨:自从换了typecho,博客也不怎么出问...
王叨叨:我准备给我的老笔记本搞一个linux系...
大D:台式机现在只能是AMD YES!
springwood:查询了一下,ThinkPad x1c 9th ...
黑石:特斯拉和小米,选哪个?不是很懂车,就...
Huo:电车的确开着舒服,也是纠结想换电车,...
zwwooooo:类似以前做网站开发时,一开始有自...
老陳网志:有点高端,像我们整点nas玩玩就够...