Example of configuring a security group for servers in a private network behind a load balancer
Configuration goal
Configure a security group to receive traffic from a load balancer on target group servers.
Prerequisites
In this configuration example, we used a cloud load balancer and two cloud servers in the same pool.
The load balancer and servers are located in a private subnet 172.16.0.0/28, and traffic filtering (port security) is enabled in the network. Servers accept TCP traffic from the load balancer on port 80, and availability checks of the PING type are configured.
Configuration result
A security group has been created and assigned to the servers, allowing them to receive incoming traffic and availability checks from the load balancer.
All outgoing traffic from the servers is allowed.
Configuration steps
Control panel
OpenStack CLI
Terraform
-
In the Control panel, click Products in the top menu and select Cloud Servers.
-
Go to the Security Groups section.
-
Click Create security group.
-
Choose the location where the target group servers are located.
-
Create a rule in the group that will allow incoming traffic from the load balancer.
5.1. Click Add incoming traffic rule.
5.2. Select the protocol — TCP.
5.3. Select traffic source (Source) — CIDR and enter the IP address of the load balancer subnet; in this example —
172.16.0.0/28. The load balancer can be recreated with a different IP address within the subnet, so you must specify the entire subnet as the traffic source.5.4. Enter the port (Dst. port) to which traffic is allowed to be received; in this example —
80.5.5. Optional: enter a comment for the rule.
5.6. Click Add.
-
Create a rule in the group to allow availability checks from the load balancer:
6.1. Click Add incoming traffic rule.
6.2. Select the protocol — ICMP.
6.3. Select traffic source (Source) — CIDR and enter the IP address of the load balancer subnet; in this example —
172.16.0.0/28. The load balancer can be recreated with a different IP address within the 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.
-
In the Ports block, select the server ports of the target group to which the security group will be assigned. After the group is created, all active sessions on the selected ports that do not comply with the group rules will be terminated.
-
Enter a group name or leave the name that was created automatically.
-
Optional: enter a comment for the group.
-
Click Create security group.