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

Create a rule for HTTP or HTTPS traffic

  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 the protocol for receiving traffic — HTTP or HTTPS.

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

  7. Optional: Enter the allowed CIDR — IP addresses from which the balancer will accept traffic with the selected protocol and port. You can enter a subnet in CIDR format or a single IP address with a /32 mask. If you leave the field blank, the balancer will accept traffic from any IP addresses. You can specify the allowed IP addresses in the rule after the balancer is created.

    If this field is absent, port security is disabled on the balancer's network.

  8. If you selected HTTPS protocol, specify a certificate for HTTPS traffic termination on the load balancer — select a certificate from the Secrets Manager or download a new one. For more information, see the TLS(SSL)-Certificates for Load Balancer instruction.

  9. Select the default target group or create a new target group with HTTP protocol. Traffic that does not match HTTP policies will be directed to the default target group . To discard traffic that does not fall under HTTP policies, select No Target Group.

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

  11. Optional: create HTTP policies:

    11.1.Click Add New Policy.

    11.2.Select the parameter for which the query will be checked:

    • HOSTNAME — to check the domain name;
    • PATH — to check the path.

    11.3.Select the type of match to the reference value:

    • EQUAL TO — match;
    • STARTS WITH. — begins with;
    • ENDS WITH. — ends with;
    • CONTAINS — Contains;
    • REGEX — regular expression.

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

    11.5.Optional: To add another condition to the policy, click New Condition and customize it. If there are multiple conditions in the policy, the request must match each of them to fall under the policy.

    11.6.Specify where to redirect the matching request:

    • Direct to a target group — select a target group or create a new one with the HTTP protocol;
    • URL redirect — 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 URL requests. For example, if you enter https://example.com/new, then the request to https://example.com/api will be forwarded to https://example.com/new/api

    To not accept requests that match the policy, select Deny Traffic.

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

    11.8. Click Add.

    11.9 Optional: To add another policy, click Add New Policy and configure it.

  12. Optional: change the connection settings, to do this, open the Advanced Rule Settings block and specify:

    • 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.
  13. Click Create.