sécurisation d'apache
This commit is contained in:
parent
09259162d3
commit
2bbd533024
scripts/server-httpd
|
@ -42,6 +42,52 @@ fi
|
|||
# Configuration SSL
|
||||
setup_ssl "$FQDN"
|
||||
|
||||
./add_domain_ssl.sh "$FQDN"
|
||||
# Sécurisation des accès
|
||||
echo "=== Sécurisation des accès ==="
|
||||
cat <<EOF > /etc/apache2/conf-available/security.conf
|
||||
<Directory />
|
||||
AllowOverride None
|
||||
Require all denied
|
||||
</Directory>
|
||||
|
||||
echo "✅ Installation et configuration réussies !"
|
||||
<FilesMatch "\.(htaccess|htpasswd|env|ini|log|sh|bak)$">
|
||||
Require all denied
|
||||
</FilesMatch>
|
||||
EOF
|
||||
a2enconf security
|
||||
|
||||
# Renforcement des en-têtes HTTP
|
||||
echo "=== Renforcement des en-têtes HTTP ==="
|
||||
cat <<EOF >> /etc/apache2/conf-available/security.conf
|
||||
ServerTokens Prod
|
||||
ServerSignature Off
|
||||
TraceEnable Off
|
||||
Header always unset X-Powered-By
|
||||
EOF
|
||||
|
||||
# Activer HTTP Strict Transport Security (HSTS)
|
||||
echo "Header always set Strict-Transport-Security \"max-age=31536000; includeSubDomains; preload\"" >> /etc/apache2/sites-available/default-ssl.conf
|
||||
|
||||
# Limitation de la taille des requêtes
|
||||
echo "=== Limitation de la taille des requêtes ==="
|
||||
echo "LimitRequestBody 10485760" >> /etc/apache2/conf-available/security.conf
|
||||
|
||||
# Vérifier la configuration avant rechargement
|
||||
echo "=== Vérification de la configuration Apache ==="
|
||||
apachectl configtest
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "❌ Erreur dans la configuration Apache !"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Appliquer des permissions sécurisées
|
||||
echo "=== Sécurisation des permissions des fichiers de configuration ==="
|
||||
chmod 640 /etc/apache2/sites-available/*
|
||||
chmod 640 /etc/apache2/conf-available/*
|
||||
chown root:root /etc/apache2/sites-available/*
|
||||
chown root:root /etc/apache2/conf-available/*
|
||||
|
||||
# Rechargement final d'Apache
|
||||
systemctl reload apache2
|
||||
|
||||
echo "✅ Installation et sécurisation d'Apache terminées !"
|
||||
|
|
Loading…
Reference in New Issue