Answer the question
In order to leave comments, you need to log in
How to balance NGINX?
Hello everyone, help the teapot figure it out. I comprehend NGINX, namely its upstream balancing
. What I have: 3 virtual machines.
1. virtualka NGINX
2 and 3 is a web server
Here is my simple config
upstream web {
ip_hash;
server 192.168.1.2:80; // тут веб 1
server 192.168.1.3:80 backup; // тут веб 2
}
server {
listen 80;
location / {
proxy_pass http://web/;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
}
}
Answer the question
In order to leave comments, you need to log in
> Maybe I'm missing some point
Yeah, you're missing out. Reading documentation is called
backup
... The parameter cannot be used with the hash, ip_hash , and random
load balancing methods .
Here is an answer about ip_hash How to avoid 10 common mistakes in setting up NGINX
But read the rest too.
Gentlemen, tell me if it is possible to
somehow substitute addresses or domains from upstream in the
proxy_set_header Host (substitute the right one)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question