Bạn tạo ba security group. Mỗi security group chỉ nhận traffic từ tầng phía trước nó:
| Security group | Inbound rule | Dùng cho |
|---|---|---|
ALB-SG |
HTTP 80 từ internet (ở phần 6 bạn sẽ giới hạn lại chỉ cho CloudFront) | Application Load Balancer |
WebServer-SG |
HTTP 80 từ ALB-SG |
Các EC2 instance chạy WordPress |
Database-SG |
MySQL 3306 từ WebServer-SG |
Cơ sở dữ liệu RDS |
Mở Amazon EC2 console → Security Groups → Create security group.
Nhập các giá trị sau:
ALB-SG, Description: Security group for the internet-facing Application Load Balancer.wordpress-vpc.HTTP, Source type Anywhere-IPv4, Description HTTP from the internet.
Giữ outbound rule mặc định và chọn Create security group.
Chọn Create security group lần nữa, chọn VPC wordpress-vpc và nhập:
WebServer-SG, Description: Security group for the private WordPress web servers.HTTP, Source – gõ ALB-SG rồi chọn security group trong danh sách, Description HTTP from the ALB only.
Chọn Create security group.
Chọn Create security group lần nữa, chọn VPC wordpress-vpc và nhập:
Database-SG, Description: Security group for the RDS MySQL database.MYSQL/Aurora, Source – chọn WebServer-SG, Description MySQL from the web servers only.
Chọn Create security group.
Cả WebServer-SG và Database-SG đều không có rule cho SSH (cổng 22). Bạn kết nối vào instance bằng Session Manager.