Files
compor-academy/docker/nginx.conf
Cauê Faleiros 7c33b7a7d3
All checks were successful
CI / Validate frontend and API (push) Successful in 31s
CI / Build and publish Docker images (push) Successful in 15s
fix: defer API DNS resolution in nginx
2026-09-01 11:33:07 -03:00

27 lines
749 B
Nginx Configuration File

server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
# Docker Swarm may start this container before the API service receives a DNS
# record. Resolving through Docker DNS at request time keeps Nginx alive while
# the API starts or is replaced during a rolling deployment.
resolver 127.0.0.11 ipv6=off valid=10s;
resolver_timeout 5s;
set $api_upstream api;
location /api/ {
proxy_pass http://$api_upstream:3001;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location / {
try_files $uri $uri/ /index.html;
}
}