Skip to main content
Balance traffic by request URL
Last update:

Balance traffic by request URL

You can direct traffic to different target groups servers depending on which domain and path are specified in the request.

  1. В control panels go to Cloud platformBalancers.

  2. Open the tab Balancers → balancer page.

  3. Click Create a rule.

  4. Select HTTPS as the protocol to receive traffic. The default port 443 will be automatically selected, on which the balancer will listen for traffic.

  5. Select a certificate to terminate HTTPS traffic on the balancer — select a certificate from the Secrets Manager or download a new one. If the rule will accept traffic for multiple domains, the certificate must be valid for all domains, or add multiple certificates.

  6. Select the default target group — this is where traffic that does not fall under the HTTP Policies. Select a group from the list or create a new target groupSpecify the HTTP traffic destination protocol and port 80 for it. If you want to discard traffic that does not fall under the HTTP policy, select Without a target group.

  7. Mark it HTTP request headersthat will be transmitted to the servers.

  8. Create HTTP policyThe traffic will be balanced according to this value. To do this, press Add a new policy.

  9. To balance the request by domain name, select a validation condition: HOSTNAME — EQUAL TO.

  10. Enter the domain name without the protocol, e.g. example.com.

  11. Click New condition.

  12. To balance the query along the path, select a validation condition: PATH — STARTS WITH..

  13. Enter the text where you want the query path to begin, e.g. /api.

  14. Select an action Direct to the target group.

  15. Select the target group to which traffic that is subject to the policy will be directed. To create a new target group, click New target group и create a task force with the HTTP protocol and port 80. If you want to discard traffic that does not fall under the HTTP policy, select Without a target group.

  16. Optional: change the policy name or leave the default one generated.

  17. Click Add.

  18. Optional: open the unit Advanced rule settings and specify connection settings:

    • for incoming requests to the balancer — specify the connection timeout and maximum connections;
    • for requests from the balancer to servers — specify the connection timeout, inactivity timeout and TCP packet waiting timeout.
  19. Click Create.