Nginx反向代理
Nginx 1.20.2 安装
代理Mysql
stream和http是同级别的,不要放入http里面;不支持不同域名转发不同Mysql的功能。
nginx.conf添加如下配置:外网13306端口映射到内网IP:3306端口
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| stream { upstream mysql_3306 { hash $remote_addr consistent; server IP:3306 weight=5 max_fails=3 fail_timeout=30s; } server { listen 13306; proxy_connect_timeout 10s; proxy_timeout 30000s; proxy_pass mysql_3306; }
upstream mysql_3307 { hash $remote_addr consistent; server IP:3306 weight=5 max_fails=3 fail_timeout=30s; } server { listen 13307; proxy_connect_timeout 10s; proxy_timeout 30000s; proxy_pass mysql_3307; } server { listen 10036; proxy_connect_timeout 5s; proxy_timeout 300s; proxy_pass 10.11.7.87:3306 ; }
}
|
代理NTP
ntp时间同步服务使用端口123,协议UDP
1 2 3 4 5 6 7 8 9 10
| stream { upstream ntp_123 { server 10.11.7.22:123; } server { listen 123 udp; proxy_pass ntp_123; } }
|