Skip to main content

Create a rule for HTTP or HTTPS traffic

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

  2. Go to the Load Balancers section → Load Balancers tab.

  3. Open the load balancer page.

  4. Click Create Rule.

  5. Select the traffic reception protocol — HTTP or HTTPS.

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

  7. Optional: enter allowed CIDRs — IP addresses from which the load 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 empty, the load balancer will accept traffic from any IP address. You can specify allowed IP addresses in the rule after creating the load balancer.

    If the field is missing, traffic filtering (port security) is disabled in the load balancer network.

  8. If you selected the HTTPS protocol, specify a certificate for terminating HTTPS traffic on the load balancer — select a certificate from the secret manager or upload a new one. Learn more in the Load Balancer TLS(SSL) Certificates guide.

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

  10. Select 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 to check the request against:

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

    11.3. Select the match type for the reference value:

    • EQUAL TO — equal to;
    • STARTS WITH — starts with;
    • ENDS WITH — ends with;
    • CONTAINS — contains;
    • REGEX — regular expression.

    11.4. Enter the reference value for the 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 configure it. If a policy has multiple conditions, a request must match all of them to be caught by the policy.

    11.6. Specify where to direct matching requests:

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

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

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

    11.8. Click Add.

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

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

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