BobMilli

Untitled

Oct 29th, 2025
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # --- Règles communes renforcées ---
  2. (common_rules) {
  3.     #############################################
  4.     # 🚫 Protection contre les bots et scanners
  5.     #############################################
  6.  
  7.     # Blocage LeakIX User-Agent
  8.     @leakix_ua {
  9.         header_regexp User-Agent (?i)l9scan
  10.     }
  11.     respond @leakix_ua 403
  12.  
  13.     # Blocage IP LeakIX (auto-update possible)
  14.     @leakix_ip {
  15.         # LEAKIX_IP_PLACEHOLDER
  16.     }
  17.     respond @leakix_ip 403
  18.  
  19.     # Blocage scanners connus
  20.     @scanners {
  21.         header_regexp User-Agent (?i)(Shodan|Censys|Nmap|masscan|curl|UGAResearchAgent)
  22.     }
  23.     respond @scanners 403
  24.  
  25.     # Blocage requêtes suspectes (fichiers ou endpoints sensibles)
  26.     @sensitive_paths {
  27.         path /.env /.git/* /server-status /actuator/* /info.php /wp-admin /wp-login.php /config.php
  28.     }
  29.     respond @sensitive_paths 403
  30.  
  31.     # Blocage requêtes HTTP sans User-Agent ou vides (souvent des bots)
  32.     @no_ua {
  33.         not header User-Agent *
  34.     }
  35.     respond @no_ua 403
  36.  
  37.     #############################################
  38.     # 🧱 Durcissement HTTP
  39.     #############################################
  40.     header {
  41.         # Cacher la version serveur
  42.         -Server
  43.  
  44.         # Sécurité navigateur
  45.         X-Frame-Options "DENY"
  46.         X-Content-Type-Options "nosniff"
  47.         Referrer-Policy "strict-origin-when-cross-origin"
  48.         X-XSS-Protection "1; mode=block"
  49.  
  50.         # Empêcher la mise en cache côté client pour endpoints sensibles
  51.         @sensitive_paths Cache-Control "no-store"
  52.  
  53.         # Sécurité CSP (à adapter selon tes apps)
  54.         # Content-Security-Policy "default-src 'self'; frame-ancestors 'none'; object-src 'none';"
  55.     }
  56.  
  57.     #############################################
  58.     # 🧭 Compression & encodage
  59.     #############################################
  60.     encode gzip zstd
  61.  
  62.     #############################################
  63.     # 🪵 Logging (optionnel)
  64.     #############################################
  65.     log {
  66.         output file /etc/caddy/logs/security.log {
  67.             roll_size 5mb
  68.             roll_keep 5
  69.         }
  70.         level WARN
  71.     }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment