feat: enhance Apache config for Traefik reverse proxy
- Add RemoteIP configuration to capture real client IPs - Enable HTTPS detection via X-Forwarded-Proto header - Add security headers (X-Frame-Options, CSP, etc.) - Disable Apache WebDAV to prevent conflicts with Nextcloud - Add module activation script for remoteip and env - Optimize Directory options (FollowSymLinks without MultiViews) - Add commented alternative PHP limits for reference 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
8
apache/enable-modules.sh
Normal file
8
apache/enable-modules.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
# Active les modules Apache nécessaires pour Nextcloud derrière Traefik
|
||||
|
||||
a2enmod remoteip # Pour récupérer les vraies IPs clients
|
||||
a2enmod env # Pour SetEnvIf (détection HTTPS)
|
||||
|
||||
# Redémarre Apache
|
||||
apache2ctl graceful
|
||||
@@ -1,5 +1,37 @@
|
||||
# Configuration pour reverse proxy Traefik
|
||||
# Récupération de l'IP réelle du client via X-Forwarded-For
|
||||
RemoteIPHeader X-Forwarded-For
|
||||
RemoteIPTrustedProxy 172.16.0.0/12
|
||||
RemoteIPTrustedProxy 10.0.0.0/8
|
||||
RemoteIPTrustedProxy 192.168.0.0/16
|
||||
|
||||
# Activer la confiance des en-têtes X-Forwarded-Proto
|
||||
SetEnvIf X-Forwarded-Proto "https" HTTPS=on
|
||||
|
||||
<Directory /var/www/html/>
|
||||
Options FollowSymLinks
|
||||
Options +FollowSymLinks
|
||||
AllowOverride All
|
||||
Require all granted
|
||||
|
||||
<IfModule mod_dav.c>
|
||||
Dav off
|
||||
</IfModule>
|
||||
</Directory>
|
||||
|
||||
# Headers de sécurité (si non gérés par Traefik)
|
||||
<IfModule mod_headers.c>
|
||||
# HSTS sera géré par Traefik
|
||||
# Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains"
|
||||
|
||||
# Autres headers de sécurité
|
||||
Header always set Referrer-Policy "no-referrer-when-downgrade"
|
||||
Header always set X-Content-Type-Options "nosniff"
|
||||
Header always set X-Frame-Options "SAMEORIGIN"
|
||||
Header always set X-XSS-Protection "1; mode=block"
|
||||
Header always set X-Robots-Tag "noindex, nofollow"
|
||||
</IfModule>
|
||||
|
||||
# Logs avec IP réelle (pas l'IP de Traefik)
|
||||
<IfModule mod_remoteip.c>
|
||||
LogFormat "%a %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
|
||||
</IfModule>
|
||||
|
||||
Reference in New Issue
Block a user