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

Create a rule for HTTP or HTTPS traffic

  1. In control panel from the top menu, press Products and select Cloud servers.

  2. Go to the section Balancers → tab Balancers.

  3. Open the balancer page.

  4. Click Create a 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 mask /32. 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 has been created.

    If the field is absent, the balancer network is turned off traffic filtering (port security).

  8. If you have selected HTTPS protocol, specify a certificate for HTTPS traffic termination on the balancer — select a certificate from the secrets manager or download a new one. See the instructions for more details TLS(SSL)-certificates of the load balancer.

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

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

  11. Optional: create HTTP Policies:

    11.1. Press Add a new policy.

    11.2 Select the parameter for which the request will be checked:

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

    11.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.

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

    11.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.

    11.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.

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

    11.8. Press Add.

    11.9 Optionally: to add another policy, press Add a new policy and set it up.

  12. Optional: change connection settings To do this, open the block Advanced rule settings 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.