当前位置:Gxlcms > 数据库问题 > nginx 代理 mysql

nginx 代理 mysql

时间:2021-07-01 10:21:17 帮助过:5人阅读

 

 

2:配置stream,定义代理192.168.1.20的3306端口映射为端口2333。

# vi /opt/apps/nginx/conf/nginx.conf
……
……
events {
    use epoll;
    worker_connections  65535;
}
#stream配置
stream {
    server {
       listen 2333; 
       proxy_connect_timeout 1s;
       proxy_timeout 3s;
       proxy_pass 192.168.1.20:3306;    
    }
}
http {
……
……
}
 

 

3:开启nginx,验证代理是否生效。

技术图片

     可以看到我们现在可以通过nginx代理的端口访问到内网的mysql服务了。这也直接避免了mysql直接暴露到公网,增加些许的安全。当然,利用stream也可以实现后端服务的负载均衡。

nginx 代理 mysql

标签:环境   实验   image   inf   bar   toolbar   ash   png   make   

人气教程排行