fix: restructure nginx sample for pre-certbot deployment
This commit is contained in:
+41
-12
@@ -1,19 +1,20 @@
|
||||
# ======================
|
||||
# ANNU KUTE CED — Configuration Nginx
|
||||
# ======================
|
||||
# Ce fichier est prévu pour un déploiement en deux temps :
|
||||
# 1. Avant le certificat SSL : le bloc :80 ci-dessous sert le site en HTTP.
|
||||
# C'est aussi le prérequis de `certbot --nginx` (validation sur le port 80).
|
||||
# À ce stade, `nginx -t` doit passer sans aucun certificat.
|
||||
# 2. Après `certbot --nginx` : Certbot crée le bloc 443 (SSL) et la
|
||||
# redirection HTTP → HTTPS automatiquement. Un bloc 443 commenté est
|
||||
# fourni en bas de fichier si vous préférez configurer SSL à la main.
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name votre-domaine.com;
|
||||
return 301 https://$server_name$request_uri;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
server_name votre-domaine.com;
|
||||
root /path/to/your/site;
|
||||
index index.php index.html;
|
||||
|
||||
# SSL Configuration (adaptez selon votre certificat)
|
||||
ssl_certificate /path/to/your/certificate.crt;
|
||||
ssl_certificate_key /path/to/your/private.key;
|
||||
|
||||
# ======================
|
||||
# SÉCURITÉ
|
||||
# ======================
|
||||
@@ -69,7 +70,7 @@ server {
|
||||
# Traitement des fichiers PHP
|
||||
location ~ \.php$ {
|
||||
include fastcgi_params;
|
||||
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock; # Adaptez selon votre version PHP
|
||||
fastcgi_pass unix:/var/run/php/php8.3-fpm.sock; # Adaptez selon votre version PHP
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
|
||||
}
|
||||
@@ -108,4 +109,32 @@ server {
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header X-XSS-Protection "1; mode=block" always;
|
||||
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
||||
}
|
||||
}
|
||||
|
||||
# ======================
|
||||
# HTTPS (port 443) — après obtention du certificat
|
||||
# ======================
|
||||
# `certbot --nginx` génère automatiquement ce bloc à partir du bloc :80,
|
||||
# avec la redirection HTTP → HTTPS. Pour une configuration SSL manuelle,
|
||||
# décommentez et adaptez les chemins des certificats, en reprenant les
|
||||
# mêmes sections SÉCURITÉ, RÉÉCRITURE D'URL, PHP et OPTIMISATIONS que
|
||||
# le bloc :80 ci-dessus :
|
||||
#
|
||||
# server {
|
||||
# listen 443 ssl http2;
|
||||
# server_name votre-domaine.com;
|
||||
# root /path/to/your/site;
|
||||
# index index.php index.html;
|
||||
#
|
||||
# ssl_certificate /etc/letsencrypt/live/votre-domaine.com/fullchain.pem;
|
||||
# ssl_certificate_key /etc/letsencrypt/live/votre-domaine.com/privkey.pem;
|
||||
#
|
||||
# # ... reprendre ici les mêmes location que dans le bloc :80 ...
|
||||
# }
|
||||
#
|
||||
# # Et remplacez alors le contenu du bloc :80 par une simple redirection :
|
||||
# # server {
|
||||
# # listen 80;
|
||||
# # server_name votre-domaine.com;
|
||||
# # return 301 https://$server_name$request_uri;
|
||||
# # }
|
||||
|
||||
Reference in New Issue
Block a user