0

I am working on nginx proxy pass with load balancer and the problem is that I have 2 different url for both the backend server, let say my domain is xyzzy.com and 1 request out of 10 should go to xyz-1.com/123/xyz/andsoon and another 9 request should go to xyz-2.com/456/456/andsoon

how to achieve this using nginx configuration.

1 Answers1

0

You must provide weight to your upstream servers:

upstream myapp1 {
        server  xyz-2.com/456/456/andsoon weight=9;
        server  xyz-1.com/123/xyz/andsoon;
    }

http://nginx.org/en/docs/http/load_balancing.html#nginx_weighted_load_balancing

IVO GELOV
  • 13,496
  • 1
  • 17
  • 26
  • 1
    Using an URI prefix additionally to the server address or domain name is not allowed inside the `upstream` block. With this configuration nginx will throw an error like `nginx: [emerg] invalid host in upstream "xyz-2.com/456/456/andsoon" in ...` – Ivan Shatsky Jun 10 '22 at 19:20
  • @IvanShatsky You're right – IVO GELOV Jun 14 '22 at 10:13