Files
obdx-web/nginx.conf
kang a3381cbfd8 nginx: reverse-proxy legacy /scan.html /demo.html /report/* alongside /api/*
These paths are still served by the old FastAPI container (now obdx-api),
so the new landing nginx must forward them upstream instead of letting the
SPA fallback swallow them.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 16:35:50 +08:00

53 lines
1.8 KiB
Nginx Configuration File

server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_types text/plain text/css text/xml application/json application/javascript application/xml+rss application/atom+xml image/svg+xml;
# Hash-named assets (Vite emits hashed filenames in /assets/) — long cache
location ~* ^/assets/.*\.(js|css|woff2?|ttf|otf|eot)$ {
expires 1y;
add_header Cache-Control "public, immutable";
try_files $uri =404;
}
# Brand images — versioned via filename, long cache
location ~* ^/brand/.*\.(png|jpg|jpeg|svg|webp|gif|ico)$ {
expires 30d;
add_header Cache-Control "public, max-age=2592000";
try_files $uri =404;
}
# Reverse proxy to FastAPI backend container (legacy obdx-web → obdx-api).
# Covers: /api/v1/* + the three legacy HTML pages and report subpaths that
# the old container still serves. Everything else falls through to the SPA.
location ~ ^/(api/|scan\.html$|demo\.html$|report/) {
proxy_pass http://obdx-api:8080;
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_read_timeout 60s;
proxy_connect_timeout 5s;
}
# SPA fallback — every non-asset path returns index.html so client routes work
location / {
try_files $uri $uri/ /index.html;
add_header Cache-Control "no-cache";
}
# Healthcheck for Coolify / load balancer
location = /healthz {
access_log off;
return 200 'ok';
add_header Content-Type text/plain;
}
}