FreeBSD NGINX TCP转发
前几天搞转发,研究了下TCP
转发,现在记录下来
首先加载模块
注意:这是FreeBSD
的位置。并且需要NGINX
支持
- load_module
该部分不属于http {}
部分,不能写在里面
TCP转发
- stream {
- server {
- listen 25565;
- proxy_connect_timeout 5s;
- proxy_timeout 20s;
- proxy_pass 0.0.0.0:25565;
- # socket 转发
- # proxy_pass unix:/var/lib/mysql/mysql.socket;
- }
- }
UDP转发
- stream {
- server {
- listen 233 udp;
- proxy_pass 127.0.0.1:3366;
- }
- }
另外还有一个backlog参数
- backlog=number
- sets the backlog parameter in the listen() call that limits the maximum length for the queue of pending connections. By default, backlog is set to -1 on FreeBSD, DragonFly BSD, and macOS, and to 511 on other platforms.
- 意思是FreeBSD, DragonFly BSD, and macOS平台默认为`-1`,其他,比如Linux,默认为`511`。