1,安装nginx tcp插件
patch -p1 < nginx_tcp_proxy_module-master/tcp.patch
./configure -prefix=/wdzj/lnmp/nginx --user=nginx --group=nginx --add-module=/wdzj/source/master/nginx_tcp_proxy_module-master/
2,配置nginx.conf
cat nginx.conf 1 worker_processes 2; 2 events { 3 worker_connections 65535; 4 } 5 6 #mysql1 7 tcp { 8 timeout 1d; 9 proxy_read_timeout 10d; 10 proxy_send_timeout 10d; 11 proxy_connect_timeout 30; 12 upstream mysql1 { 13 server 1.1.1.1:3306; 14 } 15 server { 16 allow ip; 17 allow 10.0.0.0/8; 18 deny all; 19 access_log logs/access_mysql1.log; 20 listen 13306; 21 proxy_pass mysql1; 22 so_keepalive on; 23 tcp_nodelay on; 24 } 25 } 26 27 #mysql2 28 tcp { 29 timeout 1d; 30 proxy_read_timeout 10d; 31 proxy_send_timeout 10d; 32 proxy_connect_timeout 30; 33 upstream mysql2 { 34 server 2.2.2.2:3306; 35 } 36 server { 37 allow ip; 38 allow 10.0.0.0/8; 39 deny all; 40 access_log logs/access_mysql2.log; 41 listen 13307; 42 proxy_pass mysql2; 43 so_keepalive on; 44 tcp_nodelay on; 45 } 46 }
时间: 2024-11-06 21:54:17