# ============================================
# USER MANAGER v4.0 - LAYER 1: MODSECURITY
# Servizio: Webmin
# Porta dedicata: 10000
# ============================================
# IMPORTANTE: Questo blocco va DENTRO <VirtualHost>
# PHP: 8.1+ (usa set-cookies-template.php)
# ============================================

<IfModule security2_module>
    SecRuleEngine On
    
    # Include whitelist globale
    Include /etc/modsecurity/usermanager-global-whitelist.conf
    
    # Include whitelist servizio
    Include /etc/modsecurity/usermanager-whitelist-{SERVICE_NAME}.conf
    
    # Escludi file User Manager
    SecRule REQUEST_URI "^/(set-cookies\.php|403\.(html|php))" "id:7000001,phase:1,pass,nolog,ctl:ruleEngine=Off"
    
    # Include deny-all
    Include /etc/modsecurity/usermanager-deny-all.conf
    
    <LocationMatch "^/403\.(html|php)$">
        SecRuleEngine Off
    </LocationMatch>
    
    <LocationMatch "^/set-cookies\.php$">
        SecRuleEngine Off
    </LocationMatch>
</IfModule>

# ErrorDocument
ErrorDocument 403 /403.php
