【nginx】用stream模块实现TCP端口转发 - Go语言中文社区

【nginx】用stream模块实现TCP端口转发


一、实验目的

将本机的6033端口转发至本机3306

 

二、安装

# yum  -y install  maridb*  nginx

 

 三、配置

设置selinux为宽松模式

# setenforce 0

# sed -i 's/^SELINUX=.*/SELINUX=permissive/g'   /etc/selinux/config

 

# systemct start maridb

# systemct enable maridb 

# mysql_secure_installation

 

# vim  /etc/nginx/nginx.conf

####################################################

# For more information on configuration, see:

#   * Official English Documentation: http://nginx.org/en/docs/

#   * Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;

worker_processes auto;

error_log /var/log/nginx/error.log;

pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/nginx/README.dynamic.

include /usr/share/nginx/modules/*.conf;

events {

    worker_connections 1024;

}

stream {

    proxy_timeout 30m;

    server {

        listen 192.168.1.104:6033;

        proxy_pass 127.0.0.1:3306;

    }

}

######################################################

 

# systemctl  start nginx

# systemctl  enable nginx 

# systemctl  status  nginx

 

四、测试

#  mysql  -u root  -p"MySQL@123"

#  mysql  -u root -P 6033 -p"MySQL@123"

 

五、参考

 

nginx启用stream日志配置文件

https://www.cnblogs.com/cheyunhua/p/8823496.html

利用nginx的stream模块实现内网端口的转发代理

https://blog.51cto.com/icenycmh/2117844

Module ngx_stream_core_module

http://nginx.org/en/docs/stream/ngx_stream_core_module.html

Nginx基于TCP/UDP端口的四层负载均衡(stream模块)配置梳理

https://cloud.tencent.com/developer/article/1027563

版权声明:本文来源CSDN,感谢博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/michaelwoshi/article/details/97163777
站方申明:本站部分内容来自社区用户分享,若涉及侵权,请联系站方删除。
  • 发表于 2020-03-07 23:21:42
  • 阅读 ( 1557 )
  • 分类:Go Web框架

0 条评论

请先 登录 后评论

官方社群

GO教程

猜你喜欢