Skip to main content
Example of configuring security groups for cloud servers on the same subnet
Last update:

Example of configuring security groups for cloud servers on the same subnet

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 security groups for two cloud servers to restrict the servers from accessing each other and from accessing the servers from the Internet.

What you need to customize

In the example, we used two cloud servers that are in the same pool to configure:

  • a web server is deployed on one server, the server is connected to the Internet via a public IP address;
  • a MySQL database is deployed on another server, which receives requests from the web server on standard port 3306.

Servers are added to one private subnet. Traffic filtering ( port security) is enabled on the private network and on the ports of servers on this network.

Customization result

Two security groups are created and assigned to server ports:

  • for web server — the group allows incoming HTTP and HTTPS traffic from the Internet;
  • for server with database — the group allows incoming traffic from the web server to the standard database port.

All outgoing traffic from the servers is allowed.

Customization steps

  1. Create a security group for the web server.
  2. Create a security group for the server with the database.

1. Create a security group for the Web server

  1. In the Control panel, 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 web server resides.

  5. Create a rule that allows incoming HTTP traffic to the web server:

    5.1 Click Add Inbound Rule.

    5.2 Select the protocol — TCP.

    5.3. Select the traffic source (Source) — CIDR and enter the default subnet IP address 0.0.0.0.0/0.

    5.4. Enter the port (Dst. port) that is allowed to receive traffic — 80.

    5.5 Optional: enter a comment for the rule.

    5.6. Click Add.

  6. Create a rule that allows HTTPS traffic to the web server:

    6.1 Click Add Inbound Rule.

    6.2 Select the protocol — TCP.

    6.3 Select the traffic source (Source) — CIDR and enter the default subnet IP address 0.0.0.0.0/0.

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

    6.5 Optional: enter a comment for the rule.

    6.6 Click Add.

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

  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.

2. Create a security group for the database server

  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 server with the database is located.

  5. Create a rule that allows incoming traffic from the web server group:

    5.1 Click Add Inbound Rule.

    5.2 Select the protocol — TCP.

    5.3 Select the traffic source (Source) — SG and select the security group you created for the web server.

    5.4. Enter the port (Dst. port) that is allowed to receive traffic — 3306.

    5.5 Optional: enter a comment for the rule.

    5.6. Click Add.

  6. In the Ports block, select the web server port to which the security group will be assigned. After the group is created, all active sessions that do not comply with the group's rules will be terminated on the port.

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

  8. Optional: enter a comment for the group.

  9. Click Create a security group.