events {} http { include mime.types; default_type application/octet-stream; client_max_body_size 20M; sendfile on; keepalive_timeout 65; gzip on; gzip_vary on; gzip_min_length 1024; gzip_types text/plain text/css application/json application/javascript application/xml+rss text/xml application/xml image/svg+xml; server { listen 80 default_server; root /usr/share/nginx/html; index index.html; # API -> Backend (^~ damit Regex-Locations darunter nicht greifen) location ^~ /api/ { proxy_pass http://backend:3001/api/; 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; } # Uploads -> Backend (^~ wichtig, sonst greift die .jpg-Regex-Location unten) location ^~ /uploads/ { proxy_pass http://backend:3001/uploads/; proxy_http_version 1.1; proxy_set_header Host $host; add_header Cache-Control "public, max-age=86400"; } # Cache fuer statische Assets im SPA location ~* \.(?:js|css|woff2?|ttf|eot|jpg|jpeg|png|gif|svg|ico|webp)$ { expires 1y; add_header Cache-Control "public, immutable"; try_files $uri =404; } # SPA fallback location / { try_files $uri $uri/ /index.html; } } }