Nginx implements TCP reverse proxy
By default, Nginx only supports http reverse proxy. To enable nginx to support tcp reverse proxy, you also need to add tcp proxy module support during compilation, that is, nginx_tcp_proxy_module
The following procedure only enables nginx to support tcp_proxy, without prce, gzip, ssl, and other functions. If necessary, you can add relevant parameters during compilation.
Wget https://github.com/yaoweibin/nginx_tcp_proxy_module/archive/master.zip
Unzip master
Cd nginx-1.6.2
Patch-p1 </opt/nginx_tcp_proxy_module-master/tcp. patch
./Configure -- add-module =/opt/nginx_tcp_proxy_module-master
Make
Make install
Add the following configuration in the main configuration file of nginx. conf: (you can also configure include in the main configuration file, including the configuration file for tcp forwarding.
Include/opt/nginx_tcp_proxy_module-master/tcp_proxy.conf)
Tcp {
Upstream proxy_name {
# Simple round-robin
Server 192.168.1.10: 8000;
Server 192.168.1.10: 8001;
Server 192.168.1.11: 8000;
Server 192.168.1.11: 8001;
Check interval = 3000 rise = 2 fall = 5 timeout = 1000;
# Check interval = 3000 rise = 2 fall = 5 timeout = 1000
# Check interval = 3000 rise = 2 fall = 5 timeout = 1000
# Check_http_send "GET/HTTP/1.0 \ r \ n ";
# Check_http_expect_alive http_2xxhttp_3xx;
}
Server {
Listen 8888;
Proxy_pass proxy_name;
}
}
Note:
Check interval health check, in milliseconds
After rise checks for a few normal times, add the reslserver to the load list
After the fall check fails several times, remove the realserver
Timeout check timeout time, in milliseconds
Specific to view the nginx_tcp_proxy_module-master/README, very detailed.
-------------------------------------- Split line --------------------------------------
Thoughts on how to configure and set up Nginx reverse proxy
Deployment of Nginx + MySQL + PHP in CentOS 6.2
Build a WEB server using Nginx
Build a Web server based on Linux6.3 + Nginx1.2 + PHP5 + MySQL5.5
Performance Tuning for Nginx in CentOS 6.3
Configure Nginx to load the ngx_pagespeed module in CentOS 6.3
Install and configure Nginx + Pcre + php-fpm in CentOS 6.4
Nginx installation and configuration instructions
Nginx log filtering using ngx_log_if does not record specific logs
Nginx details: click here
Nginx: click here
This article permanently updates the link address: