Skip to content

Commit 0c5ccf8

Browse files
fix(nginx): use resolver and variable proxy_pass for dynamic DNS
Nginx crashes on startup if upstream hostnames (api.anyplot.ai) cannot be resolved. Use Google DNS resolver and set variables for proxy_pass so nginx resolves at request time instead of startup. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent a16fd8d commit 0c5ccf8

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

app/nginx.conf

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ server {
3434
listen 8080;
3535
server_name _;
3636

37+
# Use Google DNS for dynamic upstream resolution (prevents startup crash when domain not yet in DNS)
38+
resolver 8.8.8.8 8.8.4.4 valid=300s;
39+
resolver_timeout 5s;
40+
3741
# Root directory for serving files
3842
root /usr/share/nginx/html;
3943
index index.html;
@@ -60,7 +64,8 @@ server {
6064

6165
# Named location for bot SEO proxy
6266
location @seo_proxy {
63-
proxy_pass https://api.anyplot.ai/seo-proxy$request_uri;
67+
set $seo_backend https://api.anyplot.ai;
68+
proxy_pass $seo_backend/seo-proxy$request_uri;
6469
proxy_set_header Host api.anyplot.ai;
6570
proxy_ssl_server_name on;
6671
proxy_ssl_verify on;
@@ -92,7 +97,8 @@ server {
9297

9398
# Proxy sitemap.xml to backend API (dynamic generation)
9499
location = /sitemap.xml {
95-
proxy_pass https://api.anyplot.ai/sitemap.xml;
100+
set $sitemap_backend https://api.anyplot.ai;
101+
proxy_pass $sitemap_backend/sitemap.xml;
96102
proxy_set_header Host api.anyplot.ai;
97103
proxy_ssl_server_name on;
98104
}

0 commit comments

Comments
 (0)