Question: How to Load Balance to Backend Using Nginx
October 17, 2024 08:53PM
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!
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 197
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready