-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathnginx.conf
41 lines (34 loc) · 1.32 KB
/
nginx.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
server {
listen 80;
server_name example.com;
root /usr/share/nginx/html;
index index.html;
gzip on;
gzip_types text/plain text/css application/javascript application/json application/xml application/xml+rss text/javascript;
gzip_min_length 1000;
# Gestion des fichiers statiques (images, CSS, JS, etc.)
location ~* \.(jpg|jpeg|png|gif|svg|ico|css|js|woff|woff2|ttf|eot)$ {
root /usr/share/nginx/html;
expires 30d;
add_header Cache-Control "public, no-transform";
}
# Gestion des routes React (SPA)
location / {
try_files $uri /index.html;
}
# Gestion spécifique du fichier env.js (si utilisé pour les variables d'env frontend)
location /env.js {
root /usr/share/nginx/html;
add_header Cache-Control "no-cache, no-store, must-revalidate";
add_header Pragma "no-cache";
add_header Expires 0;
try_files $uri =404;
}
# Redirection des erreurs 404 vers index.html (nécessaire pour React Router)
error_page 404 /index.html;
# Sécurité
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header Referrer-Policy "strict-origin-when-cross-origin";
}