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

Balance traffic by request URL

You can direct traffic to different server targets depending on which domain and path are specified in the request.

  1. In the dashboard, on the top menu, click Products and select Cloud Servers.

  2. Go to BalancersBalancers tab.

  3. Open the balancer page.

  4. Click Create Rule.

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

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

  7. Select the default target group — traffic that is not subject to 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 discard traffic that does not fall under the HTTP policy, select No target group.

  8. Mark the HTTP request headers that will be passed to the servers.

  9. Create an HTTP policy that will be used for traffic balancing. To do this, click Add New Policy.

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

  11. Enter the domain name without the protocol, such as example.com.

  12. Click New Condition.

  13. To balance the query by path, select the check condition: PATH — STARTS WITH.

  14. Enter the text where the request path should begin, e.g. /api.

  15. Select the Direct to Target action.

  16. Select the target group to which traffic that is subject to the policy will be forwarded. 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 discard traffic that does not fall under the HTTP policy, select No Target Group.

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

  18. Click Add.

  19. Optional: open the Advanced Rule Settings block and specify the 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.
  20. Click Create.