Load balance traffic by request URL
You can direct traffic to different target groups of servers depending on the domain and path specified in the request.
Control panel
OpenStack CLI
-
In the control panel, on the top menu, click Products and select Cloud Servers.
-
Go to the Load Balancers section → Load Balancers tab.
-
Open the load balancer page.
-
Click Create Rule.
-
Select the traffic reception protocol — HTTPS. The standard port 443 will be automatically selected, on which the load balancer will listen for traffic.
-
Select a certificate to terminate HTTPS traffic on the load balancer — choose a certificate from the secret manager or upload a new one. If the rule is to receive traffic for multiple domains, the certificate must be valid for all domains, or add multiple certificates.
-
Select a default target group — traffic that does not fall under any HTTP policies will be directed there. Select a group from the list or create a new target group, specify the HTTP traffic destination protocol and port 80 for it. If you want to drop traffic that does not fall under an HTTP policy, select Without target group.
-
Select the HTTP request headers that will be passed to the servers.
-
Create an HTTP policy to use for traffic balancing. To do this, click Add new policy.
-
To balance a request by domain name, select the check condition: HOSTNAME — EQUAL TO.
-
Enter the domain name without the protocol, for example
example.com. -
Click New condition.
-
To balance a request by path, select the check condition: PATH — STARTS WITH.
-
Enter the text that the request path should start with, for example
/api. -
Select the Redirect to target group action.
-
Select the target group where traffic that matches the policy will be directed. To create a new target group, click New target group and create a target group with the HTTP protocol and port 80. If you want to drop traffic that does not fall under an HTTP policy, select Without target group.
-
Optional: change the policy name or leave the one generated by default.
-
Click Add.
-
Optional: open the Advanced rule settings block and specify the connection settings:
- for incoming requests to the load balancer — specify the connection timeout and maximum number of connections;
- for requests from the load balancer to servers — specify the connection timeout, inactivity timeout, and TCP packet wait timeout.
-
Click Create.