Skip to main content
Example of configuring a security group for servers in a private network behind a load balancer
Last update:

Example of configuring a security group for servers in a private network behind a load balancer

carefully

We do not recommend configuring security groups on existing networks where a load balancer or cloud database cluster is running, as this can cause the load balancer to fail and disrupt replication in the cluster. To avoid failures and data loss, to configure groups , create a new private network or public subnet and enable traffic filtering in it.:::

Purpose of customization

Configure the security group to accept traffic from the load balancer on the target group servers.

What you need to customize

In the example, we used a cloud balancer and two cloud servers in the same pool for configuration.

The balancer and servers are located in a private subnet 172.16.0.0.0/28, traffic filtering (port security) is enabled in the network . Servers receive TCP traffic from the balancer on port 80, availability checks with PING type are configured.

Customization result

Created and assigned to servers a security group that allows incoming traffic and availability checks to be accepted from the balancer.

All outgoing traffic from the servers is allowed.

Customization steps

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

  2. Go to the Security Groups section.

  3. Click Create a security group.

  4. Select the pool where the target group's servers reside.

  5. Create a rule in the group that will allow incoming traffic from the balancer.

    5.1 Click Add Inbound Rule.

    5.2 Select the protocol — TCP.

    5.3 Select the traffic source (Source) — CIDR and enter the IP address of the balancer subnet, in the example — 172.16.0.0/28. The balancer can be recreated with a different IP address within a subnet, so you must specify the entire subnet as the traffic source.

    5.4 Enter the port (Dst. port) on which traffic is allowed to be received, in the example, 80.

    5.5 Optional: enter a comment for the rule.

    5.6. Click Add.

  6. Create a rule in the group that will allow availability checks from the balancer:

    6.1 Click Add Inbound Rule.

    6.2 Select the protocol — ICMP.

    6.3 Select the traffic source (Source) — CIDR and enter the IP address of the balancer subnet, in the example — 172.16.0.0/28. The balancer can be recreated with a different IP address within a subnet, so you must specify the entire subnet as the traffic source.

    6.4 Optional: enter a comment for the rule.

    6.6 Click Add.

  7. In the Ports block, select the ports on the target group's servers to which the security group will be assigned. After the group is created, all active sessions that do not comply with the group rules will be terminated on the selected ports.

  8. Enter a name for the group or leave the name created automatically.

  9. Optional: enter a comment for the group.

  10. Click Create a security group.