Haproxy Configuring extranet access to intranet MySQL
The external network of the machine ip:106.23.22.1
Intranet Database ip:10.10.10.1
1, installation Haproxy
Yum-y Install Haproxy
Vim/etc/haproxy/haproxy.cfg
2. You need to add the following configuration in the Haproxy configuration file backend configuration (haproxy.cfg)
####### #backend后端配置 ##############
Listen MySQL
Bind 0.0.0.0:3307 #此处指定的允许哪个ip以及使用那个端口进行外网访问 (0.0.0.0 is that any server can access the database through the extranet, it is best to use the specified server for security purposes)
Mode TCP #使用TCP协议
Balance Roundrobin #使用轮询方式
Server MySQL 10.10.10.1:3306 #此处指定访问本台服务器下哪个内网的数据库ip以及端口
If you have the option Httplog parameter in the default configuration, remember to change it to option Tcplog
Restart Haproxy after completion
Service Haproxy Restart
The intranet database on the server can then be accessed on the same machine that is allowed to access the external network.
Mysql-uroot-h 106.23.22.1-p Password-p3307
Public network access intranet database--haproxy configuration