nginx proxy mysql

Background :

    My environment is windows server 2012 R2. Installed nginx-1.18.0. It is estimated that the gateway limits the tcp connection to 3306. If you don't want to modify it, just proxy it from nginx, the test environment does not matter.

deal with:

After the events section in the nginx.conf file, the configuration is added as follows:
 

events {
    worker_connections  1024;
}

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 8081; 
		proxy_connect_timeout 1s; 
		proxy_timeout 3s; 
		proxy_pass mysql; 
	} 
}

Other versions have not been tested. The great gods say that lower versions need to add modules.

Refer to other information:

https://www.cnblogs.com/yxfcnbg/p/11557425.html

https://blog.csdn.net/jijiuqiu6646/article/details/78675891

Guess you like

Origin blog.csdn.net/qq_37372909/article/details/106276043