Multi-stage Dockerfile: node bouwt Vite output, nginx serveert dist/. nginx.conf: SPA try_files fallback, gzip, cache headers voor /assets/. .dockerignore: houdt build context schoon (node_modules, dist, .git). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
31 lines
906 B
Nginx Configuration File
31 lines
906 B
Nginx Configuration File
server {
|
|
listen 80;
|
|
server_name _;
|
|
|
|
root /usr/share/nginx/html;
|
|
index index.html;
|
|
|
|
# Gzip voor tekstuele assets
|
|
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;
|
|
|
|
# Cache hashed assets uit de Vite build (bestandsnaam bevat hash)
|
|
location /assets/ {
|
|
expires 1y;
|
|
add_header Cache-Control "public, immutable";
|
|
}
|
|
|
|
# SPA fallback: stuur alle onbekende routes naar index.html
|
|
# zodat React Router de routes /bedankt, /inschrijven etc. afhandelt
|
|
location / {
|
|
try_files $uri $uri/ /index.html;
|
|
}
|
|
|
|
# index.html zelf nooit cachen, anders zie je geen nieuwe deploys
|
|
location = /index.html {
|
|
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
|
expires 0;
|
|
}
|
|
}
|