events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; gzip on; gzip_vary on; gzip_proxied any; gzip_comp_level 6; gzip_types text/plain text/css text/xml text/javascript application/json application/javascript application/xml+rss; server { listen 80; server_name localhost; root /usr/share/nginx/html; index index.html; # Proxy /api → backend (sans Traefik) # 127.0.0.11 = DNS interne Docker, résolution dynamique via variable resolver 127.0.0.11 valid=10s; set $backend "faildaily_backend_local"; location ^~ /api/ { # Sans URI dans proxy_pass : nginx passe le chemin complet tel quel proxy_pass http://$backend:3000; 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 Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_read_timeout 60s; } # Proxy /uploads → backend (^~ empêche la règle regex .jpg de court-circuiter ce bloc) location ^~ /uploads/ { proxy_pass http://$backend:3000; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } # Proxy /socket.io → backend (WebSocket temps réel) location ^~ /socket.io/ { proxy_pass http://$backend:3000; 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_read_timeout 3600s; } # Cache des assets (images, fonts) location ~* \.(png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { expires 1y; add_header Cache-Control "public, immutable"; } # Pas de cache pour JS/CSS location ~* \.(js|css)$ { expires -1; add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0"; } # Configuration SPA Angular location / { try_files $uri $uri/ /index.html; } # Santé du conteneur location /health { access_log off; return 200 "healthy\n"; add_header Content-Type text/plain; } } }