Open migoldfinger opened 11 months ago
Yes. When Nginx configuration parser comes to directive add_upstream
, it looks whether the referred upstream has been already parsed (and thus the referred upstreams must be declared afore), allocates new N elements for servers where N is the number of servers in the referred upstream, and then memcpy
the servers with all their attributes including weights, max_fails etc. Note that it copies only server contents. As such, in your example directive keepalive 512
has to be added in upstream combined if you require this to be there.
Well then it does not work exactly the way I did think.
My hope was that combined did a round robin between upstream1 and upstream2
And the defined upstreames did work as separated enties only when they are chosen by the round robin of combined. Well I think I have to create separated config entries for that....
Directive add_upstream
does simple mechanical substitution of servers from the referred upstream into the target upstream. The servers inside the target upstream no longer comprise the structure of original upstreams.
If you want to jump between the original upstreams as the whole entities, consider using upstrand
block which is also defined in this module.
upstream upstream1{
keepalive 512;
server server1:1234 weight=10 max_fails=2 fail_timeout=30s;
server server2:1234 weight=5 max_fails=2 fail_timeout=30s;
server server3:1234 backup;
}
upstream upstream2{
keepalive 512;
server server4:1234 weight=10 max_fails=2 fail_timeout=30s;
server server5:1234 weight=5 max_fails=2 fail_timeout=30s;
server server6:1234 backup;
}
upstrand combined {
upstream upstream1;
upstream upstream2;
}
Upstrands keep structure of the referred upstreams and can be regarded as 2d arrays of upstreams.
You cannot access upstrands in proxy_pass
by name: use variables with prefix $upstrand_
. In this example
location /us1 {
proxy_pass http://$upstrand_ucombined;
}
Hi,
This module is exactly what I was looking for. I do have one question is a config like this supported and does it work like I think it should
Is something like that supported or are the settings ignored?