server { listen 80; listen [::]:80; server_name _; location /static/ { alias /var/www/html/static/; expires 1y; add_header Cache-Control "public, immutable"; access_log off; } location /media/ { alias /var/www/html/media/; expires 30d; add_header Cache-Control "public"; } location /assets { root /usr/share/nginx/html; expires 1y; add_header Cache-Control "public, immutable"; } location /api/ { proxy_pass http://backend:8000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; 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_cache_bypass $http_upgrade; proxy_connect_timeout 60s; proxy_send_timeout 60s; proxy_read_timeout 60s; } location / { root /usr/share/nginx/html; index index.html try_files $uri $uri/ /index.html; # Cache busting pour index.html add_header Cache-Control "public, max-age=0, must-revalidate"; } location ~ /\. { deny all; access_log off; log_not_found 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 "no-referrer-when-downgrade" always; add_header Permissions-Policy "geolocation=(), microphone=(), camera=()" always; gzip on; gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss; gzip_min_length 1000; error_page 404 /index.html; error_page 500 502 503 504 /50x.html; }