Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # --- Règles communes renforcées ---
- (common_rules) {
- #############################################
- # 🚫 Protection contre les bots et scanners
- #############################################
- # Blocage LeakIX User-Agent
- @leakix_ua {
- header_regexp User-Agent (?i)l9scan
- }
- respond @leakix_ua 403
- # Blocage IP LeakIX (auto-update possible)
- @leakix_ip {
- # LEAKIX_IP_PLACEHOLDER
- }
- respond @leakix_ip 403
- # Blocage scanners connus
- @scanners {
- header_regexp User-Agent (?i)(Shodan|Censys|Nmap|masscan|curl|UGAResearchAgent)
- }
- respond @scanners 403
- # Blocage requêtes suspectes (fichiers ou endpoints sensibles)
- @sensitive_paths {
- path /.env /.git/* /server-status /actuator/* /info.php /wp-admin /wp-login.php /config.php
- }
- respond @sensitive_paths 403
- # Blocage requêtes HTTP sans User-Agent ou vides (souvent des bots)
- @no_ua {
- not header User-Agent *
- }
- respond @no_ua 403
- #############################################
- # 🧱 Durcissement HTTP
- #############################################
- header {
- # Cacher la version serveur
- -Server
- # Sécurité navigateur
- X-Frame-Options "DENY"
- X-Content-Type-Options "nosniff"
- Referrer-Policy "strict-origin-when-cross-origin"
- X-XSS-Protection "1; mode=block"
- # Empêcher la mise en cache côté client pour endpoints sensibles
- @sensitive_paths Cache-Control "no-store"
- # Sécurité CSP (à adapter selon tes apps)
- # Content-Security-Policy "default-src 'self'; frame-ancestors 'none'; object-src 'none';"
- }
- #############################################
- # 🧭 Compression & encodage
- #############################################
- encode gzip zstd
- #############################################
- # 🪵 Logging (optionnel)
- #############################################
- log {
- output file /etc/caddy/logs/security.log {
- roll_size 5mb
- roll_keep 5
- }
- level WARN
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment