nginx reverse proxy all requests to two upstream servers?
I need to adjust a nginx reverse proxy which used to front a single server to send all requests it receives to two different upstream servers.
I was thinking I could do it with the configuration below, but I wasn't sure if that would work and if I'd have to use re-write rules instead?
upstream original_upstream {
server <ip address>
}
upstream new_upstream {
server <ip address>
}
server {
location / {
proxy_pass http://original_upstream;
}
location / {
proxy_pass http://new_upstream;
}
}
Any suggestions?
Solution 1:
define your upstream servers like
upstream yourname {
server <ip serverA>;
server <ip serverB>;
}
(use weight or backup in your upstream conf if needed)
and use this upstream within your location
location / {
proxy_pass http://yourname;
}