Le firewall M2S est un firewall stateful qui filtre le trafic au niveau du réseau.
| Direction | Politique |
|---|---|
| Entrant (INPUT) | DENY - Tout est bloqué par défaut |
| Sortant (OUTPUT) | ALLOW - Tout est autorisé |
| Transite (FORWARD) | DENY - Tout est bloqué |
Depuis l’espace client → Réseau → Firewall :
Rule 1: ALLOW TCP 22 (SSH) depuis 0.0.0.0/0
Rule 2: ALLOW TCP 80 (HTTP) depuis 0.0.0.0/0
Rule 3: ALLOW TCP 443 (HTTPS) depuis 0.0.0.0/0
Rule 4: ALLOW ICMP (ping) depuis 0.0.0.0/0
Ne laissez pas le port SSH (22) ouvert à tout Internet en production. Restreignez aux IPs de votre bureau ou utilisez un VPN.
En complément du firewall réseau, configurez UFW dans votre instance :
# Installation
apt install ufw
# Politique par défaut
ufw default deny incoming
ufw default allow outgoing
# Règles de base
ufw allow ssh
ufw allow http
ufw allow https
# Activer
ufw enable
# Vérifier le statut
ufw status verbose
M2S inclut une protection DDoS de base :
| Type | Protection |
|---|---|
| Volumétrique | Filtrage du trafic anormal |
| SYN Flood | Rate limiting automatique |
| Application | À configurer dans l’instance |
# Limiter les connexions SSH
ufw limit ssh
# Installer fail2ban
apt install fail2ban
systemctl enable --now fail2ban
# Configuration fail2ban
cat > /etc/fail2ban/jail.local << EOF
[sshd]
enabled = true
maxretry = 3
bantime = 3600
EOF
# Installer certbot
apt install certbot python3-certbot-nginx
# Obtenir un certificat
certbot --nginx -d exemple.com -d www.exemple.com
# Renouvellement automatique
crontab -e
# Ajouter: 0 3 * * * certbot renew --quiet
server {
listen 443 ssl http2;
server_name exemple.com;
ssl_certificate /etc/letsencrypt/live/exemple.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/exemple.com/privkey.pem;
# Configuration SSL recommandée
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256;
}