Documentation Sécurité Configuration du firewall

Configuration du firewall

10 minutes Intermédiaire

Firewall M2S

Le firewall M2S est un firewall stateful qui filtre le trafic au niveau du réseau.

Règles par défaut

DirectionPolitique
Entrant (INPUT)DENY - Tout est bloqué par défaut
Sortant (OUTPUT)ALLOW - Tout est autorisé
Transite (FORWARD)DENY - Tout est bloqué

Créer des règles

Depuis l’espace client → RéseauFirewall :

  1. Créer un groupe de règles
  2. Ajouter des règles :
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
  1. Appliquer le groupe à vos instances
Sécurité

Ne laissez pas le port SSH (22) ouvert à tout Internet en production. Restreignez aux IPs de votre bureau ou utilisez un VPN.

Firewall applicatif (UFW)

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

Protection DDoS

M2S inclut une protection DDoS de base :

TypeProtection
VolumétriqueFiltrage du trafic anormal
SYN FloodRate limiting automatique
ApplicationÀ configurer dans l’instance

Renforcer la protection

# 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

Certificats SSL/TLS

Obtenir un certificat Let’s Encrypt

# 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

Configuration Nginx

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;
}