时间:2021-07-01 10:21:17 帮助过:16人阅读
2. cat /etc/nginx/nginx.conf ,内容如下:
worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { root html; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } } stream { upstream cloudsocket { hash $remote_addr consistent; # $binary_remote_addr; server 192.168.182.155:3306 weight=5 max_fails=3 fail_timeout=30s; } server { listen 3306;#数据库服务器监听端口 proxy_connect_timeout 10s; proxy_timeout 300s;#设置客户端和代理服务之间的超时时间,如果5分钟内没操作将自动断开。 proxy_pass cloudsocket; } }
3. systemctl restart nginx ,重启nginx。
4.验证
登录192.168.182.156服务器执行看是否有3306端口的监听
[root@localhost sbin]# netstat -nap|grep 3306 tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 89870/nginx: master
用Navicat for MySQ工具测试是否能连接
nginx 代理 tcp协议 mysql 连接
标签:nsis restart set pst 数据 监听 代理 dso RKE