# ============================================================================== # Configuration Nginx pour Afficheurs Ferroviaires (React PWA) # ============================================================================== # ------------------------------------------------------------------------------ # OPTION 1 : Reverse Proxy vers PM2 / Node.js (port 4010) # ------------------------------------------------------------------------------ server { listen 80; listen [::]:80; server_name your-domain.com; # Remplacez par votre nom de domaine ou IP # Redirection HTTP vers HTTPS (à décommenter en production avec SSL) # return 301 https://$host$request_uri; # Compression Gzip gzip on; gzip_vary on; gzip_min_length 1024; gzip_proxied any; gzip_comp_level 6; gzip_types text/plain text/css text/xml text/javascript application/json application/javascript application/x-javascript application/xml application/xml+rss image/svg+xml; location / { proxy_pass http://127.0.0.1:4010; proxy_http_version 1.1; # En-têtes pour WebSockets et Realtime (Supabase / SSE) proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; # En-têtes standards 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_read_timeout 86400s; proxy_send_timeout 86400s; } } # ------------------------------------------------------------------------------ # OPTION 2 : Service direct des fichiers statiques (React Build SPA) # ------------------------------------------------------------------------------ # server { # listen 80; # listen [::]:80; # server_name your-domain.com; # # # Chemin absolu vers le dossier build de l'application # root /var/www/afficheurs-ferrovia/build; # index index.html; # # # Compression Gzip # gzip on; # gzip_vary on; # gzip_min_length 1024; # gzip_proxied any; # gzip_comp_level 6; # gzip_types # text/plain # text/css # text/xml # text/javascript # application/json # application/javascript # application/x-javascript # application/xml # application/xml+rss # image/svg+xml; # # # Routage SPA React (indispensable pour /afficheurs/*, /departs, /arrivees, etc.) # location / { # try_files $uri $uri/ /index.html; # } # # # Cache pour les assets statiques avec hash (JS/CSS) # location ~* \.(?:css|js)$ { # expires 1y; # access_log off; # add_header Cache-Control "public, max-age=31536000, immutable"; # } # # # Cache pour les médias, polices et images # location ~* \.(?:ico|png|jpg|jpeg|gif|svg|woff|woff2|ttf|eot|mp3|wav)$ { # expires 30d; # access_log off; # add_header Cache-Control "public, max-age=2592000"; # } # # # Pas de cache pour index.html, manifest.json et service-worker (mise à jour PWA instantanée) # location ~* (?:index\.html|manifest\.json|service-worker\.js)$ { # expires -1; # add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0"; # } # }