Files
Tautvydas Derzinskas 4d4d2209e6 fix: allow slow API requests through nginx and explain proxy errors
Raise the /api proxy timeout from 60s to 300s, the longest AI timeout the
settings allow. When a proxy answers with an HTML error page, show a short
message instead of the raw HTML.
2026-10-11 21:16:56 +02:00

49 lines
1.7 KiB
Nginx Configuration File

server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
# Proxy all /api/* requests to the backend container.
# ^~ forces this prefix match to win over the regex location below -- without it, any
# backend route ending in one of those extensions (e.g. /api/plate/:id/thumb.jpg, or a
# plate file download named *.png/*.svg) gets shadowed by the static-asset block and
# 404s straight out of nginx instead of ever reaching the backend.
location ^~ /api/ {
proxy_pass http://backend:8000;
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;
# Long enough for the slowest request: a slow local AI model may take up to the 300s
# timeout its settings allow.
proxy_read_timeout 300s;
client_max_body_size 512m;
}
# SPA fallback — serve index.html for all non-file requests
location / {
try_files $uri $uri/ /index.html;
}
# Cache fingerprinted static assets aggressively
location ~* \.(js|css|woff2?|ttf|eot|svg|png|jpg|jpeg|gif|ico)$ {
expires 1y;
add_header Cache-Control "public, immutable";
access_log off;
}
location = /manifest.webmanifest {
types { }
default_type application/manifest+json;
add_header Cache-Control "no-cache";
}
# No caching for HTML (so new deployments are picked up)
location ~* \.html$ {
add_header Cache-Control "no-cache";
}
}