1. Scene
Nginx3 connecting the WAN to other servers inside the network
Nginx 1---------------------
/ \ \ \
Server 1 server 2 Server3 nginx3 <--
\ / / /
Nginx 2-----------------------
2. Ideas
NGINX3 for ingress reverse proxy, load balancer to NGINX1, 2
Nginx 1, 2 reverse proxy and load balancer Servier1, 2, 3
3. Configuration files
NGINX3 configuration:
Upstream lb.tin.com {
Server 10.221.148.167:80; #nginx1
Server 10.251.216.232:80; #nginx2
}
Upstream pro1.tin.com {
Server 10.221.148.167:80;
}
Upstream pro2.tin.com {
Server 10.251.216.232:80;
}
server {
Listen 80;
server_name loalhost;
Location/pro1 {
Proxy_pass http://pro1.tin.com;
Proxy_set_header Host $host;
Proxy_set_header X-real-ip $remote _addr;
Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;
}
Location/pro2 {
Proxy_pass http://pro2.tin.com;
Proxy_set_header Host $host;
Proxy_set_header X-real-ip $remote _addr;
Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;
}
}
NGINX1, 2 configuration:
NGINX1 Example:
Upstream pro1.tin.com {
Server 10.221.148.160:8080; #server1
Server 10.251.216.230:8080; #server2
Server 10.251.216.231:8080; #server3
}
Upstream server1.tin.com {
Server 10.221.148.160:8080;
}
Upstream server2.tin.com {
Server 10.251.216.230:8080;
}
Upstream server3.tin.com {
Server 10.251.216.231:8080;
}
server {
Listen 8080;
server_name loalhost;
Location/server1 {
Proxy_pass http://server1.tin.com;
Proxy_set_header Host $host;
Proxy_set_header X-real-ip $remote _addr;
Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;
}
Location/server2 {
Proxy_pass http://server2.tin.com;
Proxy_set_header Host $host;
Proxy_set_header X-real-ip $remote _addr;
Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;
}
Location/server3 {
Proxy_pass http://server3.tin.com;
Proxy_set_header Host $host;
Proxy_set_header X-real-ip $remote _addr;
Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;
}
}
Nginx-based load balancing