Corrige la redirection vers localhost derrière le reverse proxy
- nginx.conf: sert l'application sur 80 et 443 sans redirection interne (l'ancien "return 301 https://\$server_name" renvoyait vers localhost, server_name étant codé à localhost). NPM gère déjà le TLS/redirect public. - bootstrap/app.php: trustProxies(at: '*') pour que Laravel lise X-Forwarded-Proto/Host et génère les bonnes URL derrière NPM. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -13,6 +13,11 @@ return Application::configure(basePath: dirname(__DIR__))
|
|||||||
health: '/up',
|
health: '/up',
|
||||||
)
|
)
|
||||||
->withMiddleware(function (Middleware $middleware): void {
|
->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(ForceHttps::class);
|
||||||
$middleware->append(SecurityHeaders::class);
|
$middleware->append(SecurityHeaders::class);
|
||||||
})
|
})
|
||||||
|
|||||||
+7
-6
@@ -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 {
|
server {
|
||||||
listen 80;
|
listen 80;
|
||||||
server_name localhost;
|
|
||||||
return 301 https://$server_name$request_uri;
|
|
||||||
}
|
|
||||||
|
|
||||||
server {
|
|
||||||
listen 443 ssl;
|
listen 443 ssl;
|
||||||
server_name localhost;
|
server_name app.sam-coffre.duckdns.org localhost _;
|
||||||
|
|
||||||
ssl_certificate /var/www/cert.pem;
|
ssl_certificate /var/www/cert.pem;
|
||||||
ssl_certificate_key /var/www/cert.key;
|
ssl_certificate_key /var/www/cert.key;
|
||||||
|
|
||||||
index index.php index.html;
|
index index.php index.html;
|
||||||
root /var/www/public;
|
root /var/www/public;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user