Edge Load Balancer is actually a HAProxy and supports different ways of balancing traffic between servers. Among them, balancing HTTP requests by URI, the web address of the page, which we will consider in this article.
This way of balancing is used when you need to separate "heavy" requests from the rest of the traffic and redirect it to a separate pool of servers.
Test Infrastructure
To demonstrate this balancing method, we deployed three virtual machines in a separate vApp: web1, web2, web3.
web2 in our case will handle heavy traffic, and web1 and web3 will handle all other traffic.
Temporary fw and dnat rules were added to debug and test the web servers.
Firewall - traffic to the external IP on ports 80 to 83 is allowed.
NAT - each port is redirected to its own server
As web servers nginx was used, in addition to the home page two more pages light.html and heavy.html were added.
The configurations of the virtual machines and web servers are identical.
The differences are the hostnames, internal IP addresses, and the web pages themselves: the header for clarity shows the hostname of the webserver.
Load Balancer configuration
Global Configuration
Enabling balancing
Application Profiles
Add the application profile to be used by the virtual server.
Service Monitoring
Add monitoring of web servers. This is not required, but will allow you to monitor performance and use only "live" pool servers.
Monitor or None is selected in the next step.
Pools
Add two pools of servers: for "heavy" traffic and for all other traffic
Application Rules
Add a rule that will allow the balancer to distribute traffic into pools depending on URIs:
acl site_heavy path_beg -i /heavy
use_backend pool-web2 if site_heavy
Pages with /heavy addresses will be handed over to pool-web2 pool servers.
There can be more rules than the virtual server uses.
Virtual Servers
Add a Virtual Server. On the General tab enable it, select the application profile, external IP address, protocol, and default pool.
On the Advanced tab, select the previously defined application rules.
The result is the following settings:
Checking
Homepage
Clicking on the light link
Click on the heavy-link
URI balancing now works, setup is complete.
Examples of different rules you can find in the official documentation.