Skip to main content
Create a rule for HTTP or HTTPS traffic
Last update:

Create a rule for HTTP or HTTPS traffic

  1. В control panels go to Cloud platformBalancers.

  2. Open the tab Balancers → balancer page.

  3. Click Create a rule.

  4. Select the protocol for receiving traffic — HTTP or HTTPS.

  5. For the selected protocol, the default port on which the balancer will listen to traffic will be automatically selected — change it if necessary.

  6. If you selected the HTTPS protocol, select a certificate to terminate HTTPS traffic on the balancer — select a certificate from the Secrets Manager or download a new one. Read more in the instructions TLS(SSL)-certificates of the load balancer.

    Certificates with an empty field CN (Common Name) are not supported in load balancers.

  7. Select the default target group or create a new target group with the HTTP protocol. The default destination group will be forwarded traffic that does not match the HTTP Policies. To discard traffic that does not fall under HTTP policies, select Without a target group.

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

  9. Optional: create HTTP Policies:

    9.1. Press Add a new policy.

    9.2 Select the parameter for which the query will be checked: HOSTNAME for the domain name or PATH to check the path.

    9.3 Select the type of match to the reference value:

    • EQUAL TO — is a match;
    • STARTS WITH — begins with;
    • ENDS WITH — ends in;
    • CONTAINS — contains;
    • REGEX — regular expression.

    9.4 Enter the control value to check. If you selected the condition in step 6 REGEX, enter a regular expression.

    9.5 Optional: to add another condition to the policy, press New condition and customize it. If there are multiple conditions in the policy, the request must match each condition to fall under the policy.

    9.6 Specify where to redirect the appropriate request:

    • Direct to the target group — select a target group or create a new with the HTTP protocol;
    • Redirect to URL — enter a target URL that will completely replace the request URL, including protocol, domain name, path, and request parameters;
    • Redirect to URL prefix — enter the part of the URL to replace the protocol and domain name in the request URL. For example, if you enter https://example.com/newthen the request for https://example.com/api will be forwarded to https://example.com/new/api

    To not accept requests that match the policy, select Reject traffic.

    9.7. Enter a policy name or leave the default one generated.

    9.8. Press Add.

    9.9 Optional: to add another policy, press Add a new policy and set it up.

  10. Optional: expand 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.
  11. Click Create.