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 using security groups on existing networks, as this can cause load balancer failures and disrupt cloud database replication. To avoid failures and data loss, create a new private network or public subnet и enable traffic filtering (port security) 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 cloud server for configuration bullet:

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

The servers have been added to one private subnet. On a private network and on the ports of servers on that network traffic filtering (port security) is enabled.

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 database server.

1. Create a security group for the Web server

  1. В control panels from the top menu, press Products and select Cloud servers.

  2. Go to the section Security groups.

  3. Click Create a security team.

  4. Select pool where the web server is located.

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

    5.1. Press Add an incoming traffic rule.

    5.2 Select the protocol — TCP.

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

    5.4. Enter the port (Dst. port) on which you are allowed to receive traffic-80.

    5.5 Optional: enter a comment for the rule.

    5.6. Press Add.

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

    6.1. Press Add an incoming traffic rule.

    6.2 Select the protocol — TCP.

    6.3. Select the traffic source (Source) — 6.3. CIDR and enter the IP address of the default subnet 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. Press Add.

  7. In the block Ports check 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 team.

2. Create a security group for the database server

  1. В control panels from the top menu, press Products and select Cloud servers.

  2. Go to the section Security groups.

  3. Click Create a security team.

  4. Select pool where the database server is located.

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

    5.1. Press Add an incoming traffic rule.

    5.2 Select the protocol — TCP.

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

    5.4. Enter the port (Dst. port) on which you are allowed to receive the traffic -3306.

    5.5 Optional: enter a comment for the rule.

    5.6. Press Add.

  6. In the block Ports check 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 team.