From 2b230e756e4d1e915e1f3c435c1f6565e6f0258f Mon Sep 17 00:00:00 2001 From: aminovfariz Date: Mon, 8 Jun 2026 09:58:28 +0200 Subject: [PATCH] fix(deploy): re-resolve php upstream on each request to survive container restarts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using resolver 127.0.0.11 (Docker internal DNS) with set $php_upstream forces nginx to re-resolve the php hostname dynamically instead of caching the IP at startup — eliminates 502 after php container is recreated. Co-Authored-By: Claude Sonnet 4.6 --- deploy/nginx/site.conf | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/deploy/nginx/site.conf b/deploy/nginx/site.conf index 1f9b490..f0d046e 100644 --- a/deploy/nginx/site.conf +++ b/deploy/nginx/site.conf @@ -12,13 +12,17 @@ server { try_files $uri $uri/ /index.php?$query_string; } + # Docker DNS resolver — re-resolves php hostname on each request + resolver 127.0.0.11 valid=5s; + location ~ \.php$ { include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; # SSL терминирован на host nginx — передаём это в PHP fastcgi_param HTTPS on; fastcgi_param HTTP_X_FORWARDED_PROTO https; - fastcgi_pass php:9000; + set $php_upstream php:9000; + fastcgi_pass $php_upstream; fastcgi_hide_header Cache-Control; add_header Cache-Control "no-store, no-cache, must-revalidate, private" always; }