mirror of
https://github.com/TautvydasDerzinskas/Thingport.git
synced 2026-10-18 20:59:55 -05:00
47 lines
1.5 KiB
Nginx Configuration File
47 lines
1.5 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;
|
|
proxy_read_timeout 60s;
|
|
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";
|
|
}
|
|
}
|