upstream backend { server 127.0.0.1:{{ backend_port }} max_fails=3 fail_timeout=30s; keepalive 32; } server { listen 80; listen [::]:80; server_name {{ nginx_domain }}; root {{ nginx_frontend_path }}/dist; index index.html; access_log /var/log/nginx/{{ nginx_app_name }}.access.log; error_log /var/log/nginx/{{ nginx_app_name }}.error.log; client_max_body_size {{ nginx_max_body_size }}; location /api/ { limit_except GET POST PUT DELETE PATCH OPTIONS { deny all; } proxy_pass http://backend/; proxy_http_version 1.1; proxy_set_header Connection ""; 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_connect_timeout {{ nginx_proxy_timeout }}s; proxy_send_timeout {{ nginx_proxy_timeout }}s; proxy_read_timeout {{ nginx_proxy_timeout }}s; proxy_buffering on; proxy_buffer_size 4k; proxy_buffers 8 4k; proxy_no_cache 1; proxy_cache_bypass 1; } location / { try_files $uri $uri/ /index.html; add_header Cache-Control "no-cache, no-store, must-revalidate"; } location ~* \.(css|js)$ { expires {{ nginx_cache_static_duration }}; add_header Cache-Control "public, immutable"; access_log off; } location ~* \.(jpg|jpeg|png|gif|ico|svg|woff|woff2|ttf|eot)$ { expires {{ nginx_cache_media_duration }}; add_header Cache-Control "public, immutable"; access_log off; } location = /health { access_log off; return 200 "healthy\n"; add_header Content-Type text/plain; } add_header X-Frame-Options "SAMEORIGIN" always; add_header X-Content-Type-Options "nosniff" always; add_header X-XSS-Protection "1; mode=block" always; add_header Referrer-Policy "strict-origin-when-cross-origin" always; location ~ /\. { deny all; access_log off; log_not_found off; } location ~* (\.env|\.git|package\.json|package-lock\.json|yarn\.lock)$ { deny all; } }