diff --git a/bootstrap/app.php b/bootstrap/app.php index f2ba62f..b6e8ea4 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -13,6 +13,11 @@ return Application::configure(basePath: dirname(__DIR__)) health: '/up', ) ->withMiddleware(function (Middleware $middleware): void { + // L'application tourne derrière nginx-proxy-manager : on fait confiance + // au reverse proxy pour lire X-Forwarded-Proto/Host (sinon Laravel croit + // être en HTTP et génère de mauvaises URL / redirections). + $middleware->trustProxies(at: '*'); + $middleware->append(ForceHttps::class); $middleware->append(SecurityHeaders::class); }) diff --git a/nginx.conf b/nginx.conf index 5dc3d00..c7eb910 100644 --- a/nginx.conf +++ b/nginx.conf @@ -1,14 +1,15 @@ +# Ce serveur nginx est DERRIÈRE nginx-proxy-manager (NPM), qui termine le TLS +# public (certificat Let's Encrypt) et force déjà HTTP -> HTTPS pour le domaine. +# Ici, on se contente donc de SERVIR l'application, sans redirection interne +# (l'ancienne redirection vers https://$server_name renvoyait vers "localhost"). server { listen 80; - server_name localhost; - return 301 https://$server_name$request_uri; -} - -server { listen 443 ssl; - server_name localhost; + server_name app.sam-coffre.duckdns.org localhost _; + ssl_certificate /var/www/cert.pem; ssl_certificate_key /var/www/cert.key; + index index.php index.html; root /var/www/public; @@ -26,4 +27,4 @@ server { try_files $uri $uri/ /index.php?$query_string; gzip_static on; } -} \ No newline at end of file +}