-#map $sent_http_content_type $expires {
-# default off;
-## image/png off;
-# application/javascript epoch;
-# text/html epoch;
-# text/css epoch;
-#}
-
#https://www.nginx.com/blog/websocket-nginx/
map $http_upgrade $connection_upgrade {
default upgrade;
server {
listen *:80;
- listen [::]:80; #ipv6only=off;
+ listen [::]:80;
server_name my.server.com www.my.server.com;
return 301 https://my.server.com$request_uri;
}
server {
listen 443 ssl;
- listen [::]:443 ssl; #http2 ipv6only=off;
+ listen [::]:443 ssl;
http2 on;
server_name my.server.com;
-
- # On pointe sur le dossier généré par ton script
root /path/to/xogo/dist;
error_log /var/log/nginx/xogo_error.log;
access_log /var/log/nginx/xogo_access.log;
- # 1. Le point d'entrée : TOUJOURS vérifier s'il y a une mise à jour
+ # 1. Entry point: always check if there was an update
location = /index.html {
add_header Cache-Control "no-cache, must-revalidate";
expires 0;
}
- # 2. Les fichiers statiques hashés (JS, CSS) + Assets
- # Ils ont un hash dans le nom, donc s'ils changent, l'URL change.
- # On peut les cacher de façon agressive.
+ # 2. Static hashed files (JS, CSS) + assets: agressive caching
location / {
try_files $uri $uri/ /index.html;
expires 1y;
add_header Cache-Control "public, immutable";
}
- # 3. WebSocket : Pas de changement ici, c'est parfait
+ # 3. WebSocket server proxy
location /ws {
proxy_pass http://localhost:WS_PORT;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
- #proxy_set_header Connection "Upgrade";
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
-
- # Le cache n'a pas de sens pour un tunnel WebSocket
proxy_buffering off;
}