server { listen 80; server_name _; root /usr/share/nginx/html; index index.html; # URL puliti — /mappa trova mappa.html location / { try_files $uri $uri.html $uri/ =404; } # Pagine "scheda" con slug nel path: // -> .html # Lo slug resta leggibile lato client da location.pathname. # Elencare qui le pagine path-style reali quando esistono (deve esistere il relativo .html). # Esempio: # location ~ ^/(?artifact|institution)/[^/]+/?$ { # try_files /$page.html =404; # } # Proxy per API: inoltra /api/* al backend location /api/ { proxy_pass http://backend:8000/api/; 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; } # Documentazione utente (MkDocs) location /documentation/ { proxy_pass http://docs:8000/; 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; } # Documentazione OpenAPI (Scramble) — /api-docs/* → backend /docs/* location /api-docs/ { rewrite ^/api-docs/(.*)$ /docs/$1 break; proxy_pass http://backend:8000; 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; } # Cache aggressiva per asset con hash (Vite li genera con hash nel nome) location ~* \.(js|css|woff2|png|jpg|ico|svg)$ { expires 1y; add_header Cache-Control "public, immutable"; try_files $uri =404; } # Blocca file sensibili location ~ /\. { deny all; } # Storage per file statici location /storage/ { alias /usr/share/nginx/html/storage/; access_log off; expires 30d; } access_log /dev/stdout; error_log /dev/stderr warn; }