I am currently considering an implementation to load balance between two specified backend servers using Nginx. I understand that this is possible depending on the configuration of the upstream directive, but it hasn't been working as expected, so I would appreciate any advice or tips.
I want to dynamically specify the FQDN of the server in the upstream directive as an argument for proxy_set_header Host, but I'm having trouble achieving this. Specifically, when I have the following configuration in upstream, I would like proxy_set_header Host to include the FQDN of the server that is being load balanced within upstream. For example, if it is load balancing to server test1.example.com:443, I want proxy_set_header Host to be set to test1.example.com.
------
upstream backends {
server test1.example.com:443;
server test2.example.com:443;
}
------
By the way, when I specified only one server in upstream and hardcoded the argument for proxy_set_header Host, it worked fine.
If you have any advice regarding the above, please let me know. Thank you!