当前位置:   article > 正文

nginx配置代理访问mysql_Nginx反代代理MySQL配置实例

nginx配置代理访问mysql_Nginx反代代理MySQL配置实例

Nginx官方模块: ngx_stream_core_module --with-stream_ssl_module(ssl协议支持,比如MySQL ssl)

1、查看现有编译

--user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --with-http_flv_module --with-http_mp4_module --with-http_gzip_static_module

2、重新编译:

--user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --with-http_flv_module --with-http_mp4_module --with-http_gzip_static_module --with-stream --with-stream_ssl_module

注意:--with-stream --with-stream_ssl_module

3、配置、检测、重启nginx:

配置:

stream {

upstream mysql {

zone myapp1 64k;

server localhost:3306 weight=1 max_fails=3 fail_timeout=30s;

#server 192.168.1.221:3306 weight=1 max_fails=2 fail_timeout=30s;

}

server {

listen 2188;

proxy_connect_timeout 1s;

proxy_timeout 3s;

proxy_pass mysql;

}

}

检测:

nginx -t {conf path}

启动:

nginx -c {conf path}

查看启动后代理端口 :

netstat -atupn|grep nginx

验证:

mysql -u{username} -p{password} -h {host} -P {port}

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/230711?site
推荐阅读
相关标签
  

闽ICP备14008679号