All checks were successful
Build and Deploy Nuxt / build (push) Successful in 11s
The backend image ships no .env (gitignored) and compose passed no env, so MONGO_URI fell back to the container's own 127.0.0.1, the API died on connect, and nginx answered 502 for every /api request. - docker-compose.yml: mongo:7 service with a data volume; backend gets MONGO_URI=mongodb://mongo:27017/mathew and waits on its healthcheck - nginx.conf: resolve service names through Docker's DNS per request (stale cached IPs 502 after every container recreate); match bare /api too so it cannot loop through the frontend's SSR proxy
44 lines
1.5 KiB
Nginx Configuration File
44 lines
1.5 KiB
Nginx Configuration File
events {}
|
|
|
|
http {
|
|
# Docker's embedded DNS: resolve service names per request (cached 10s).
|
|
# nginx would otherwise resolve them once at startup and keep proxying to
|
|
# a recreated container's old IP — a 502 until nginx itself is reloaded.
|
|
resolver 127.0.0.11 valid=10s ipv6=off;
|
|
|
|
server {
|
|
listen 80;
|
|
server_name _;
|
|
|
|
# Api Requests ("/api" without a trailing slash must land here too,
|
|
# or it falls through to the frontend and loops through its SSR proxy)
|
|
location /api {
|
|
set $api_upstream backend:5000;
|
|
proxy_pass http://$api_upstream;
|
|
|
|
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;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
}
|
|
|
|
# Normal requests
|
|
location / {
|
|
set $frontend_upstream frontend:3000;
|
|
proxy_pass http://$frontend_upstream;
|
|
|
|
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;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
}
|
|
|
|
}
|
|
}
|