# ========================================================= # Request ID for correlation # ========================================================= map $http_x_request_id $req_id { default $http_x_request_id; "" $request_id; } # ========================================================= # Upstream backend # ========================================================= upstream backend { server backend:8080 max_fails=3 fail_timeout=30s; keepalive 32; keepalive_requests 100; keepalive_timeout 60s; } # ========================================================= # HTTP Server (MAIN) # ========================================================= # Supprime le premier server block et garde seulement : server { listen 80; listen [::]:80; server_name _; root /usr/share/nginx/html; index index.html; client_max_body_size 10M; modsecurity on; modsecurity_rules_file /etc/nginx/modsec/custom-rules.conf; location /api/ { limit_except GET POST PUT PATCH DELETE OPTIONS { deny all; } if ($request_method = 'OPTIONS') { add_header 'Access-Control-Allow-Origin' "$http_origin" always; add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, PATCH, DELETE, OPTIONS' always; add_header 'Access-Control-Allow-Headers' 'Authorization, Content-Type, X-Request-ID' always; add_header 'Access-Control-Allow-Credentials' 'true' always; add_header 'Access-Control-Max-Age' 86400 always; add_header 'Content-Length' 0; add_header 'Content-Type' 'text/plain charset=UTF-8'; return 204; } proxy_pass http://backend; 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; # ✅ Changé proxy_set_header X-Request-ID $req_id; proxy_set_header Connection ""; proxy_connect_timeout 60s; proxy_send_timeout 60s; proxy_read_timeout 60s; } location / { try_files $uri $uri/ /index.html; add_header Cache-Control "no-cache, no-store, must-revalidate" always; add_header Pragma "no-cache" always; add_header Expires "0" always; } location ~* \.(css|js|jpg|jpeg|png|gif|svg|ico|woff2?|ttf|eot)$ { expires 1y; add_header Cache-Control "public, immutable"; access_log off; } 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; add_header Content-Security-Policy " default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self' data:; connect-src 'self' https://api.tomtom.com; " always; location ~ /\. { deny all; access_log off; log_not_found off; } location ~* (\.env|\.git|package\.json|package-lock\.json|yarn\.lock|Dockerfile|docker-compose\.yml)$ { deny all; access_log off; log_not_found off; } }