103 lignes
3.3 KiB
Nginx Configuration File
103 lignes
3.3 KiB
Nginx Configuration File
# =============================================================
|
|
# Nginx — à placer dans conf.d/ ou sites-available/
|
|
# (le choix par défaut si tu passes par Docker / CasaOS)
|
|
# =============================================================
|
|
|
|
server {
|
|
listen 80;
|
|
server_name _;
|
|
|
|
root /usr/share/nginx/html;
|
|
index index.html;
|
|
|
|
# ---- Compression Extrême (AOT Brotli 11 & Gzip 9) --------
|
|
brotli_static on;
|
|
gzip_static on;
|
|
|
|
gzip on;
|
|
gzip_vary on;
|
|
gzip_min_length 256;
|
|
gzip_comp_level 6;
|
|
gzip_types
|
|
text/plain
|
|
text/css
|
|
text/javascript
|
|
application/javascript
|
|
application/json
|
|
image/svg+xml;
|
|
|
|
# Brotli dynamique en repli
|
|
brotli on;
|
|
brotli_comp_level 6;
|
|
brotli_types text/plain text/css application/javascript application/json image/svg+xml;
|
|
|
|
# ---- Cache ----------------------------------------------
|
|
# Assets immuables : 1 an de cache strict
|
|
location /assets/ {
|
|
expires 1y;
|
|
add_header Cache-Control "public, max-age=31536000, immutable" always;
|
|
access_log off;
|
|
}
|
|
|
|
# Document HTML : 300s (5min) avec revalidation en arrière-plan
|
|
location = /index.html {
|
|
add_header Cache-Control "public, max-age=300, stale-while-revalidate=60" always;
|
|
}
|
|
location = / {
|
|
add_header Cache-Control "public, max-age=300, stale-while-revalidate=60" always;
|
|
try_files /index.html =404;
|
|
}
|
|
|
|
# Flux actualités JSON : 300s (5min) avec revalidation en arrière-plan
|
|
location = /data/news.json {
|
|
add_header Cache-Control "public, max-age=300, stale-while-revalidate=60" always;
|
|
add_header Content-Type "application/json; charset=utf-8" always;
|
|
}
|
|
|
|
# ---- Télémétrie Système (/api/stats) --------------------
|
|
# Reverse-proxy sécurisé vers le démon local (127.0.0.1:8085)
|
|
location /api/stats {
|
|
# Restriction stricte à la méthode GET
|
|
limit_except GET {
|
|
deny all;
|
|
}
|
|
|
|
# Décommente la ligne ci-dessous si la zone limit_req_zone est active :
|
|
# limit_req zone=telemetry_ratelimit burst=4 nodelay;
|
|
|
|
proxy_pass http://127.0.0.1:8085;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Connection "";
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
|
|
# Micro-cache client (2s) : immunise contre les requêtes massives simultanées
|
|
add_header Cache-Control "public, max-age=2, stale-while-revalidate=1";
|
|
add_header X-Content-Type-Options nosniff;
|
|
}
|
|
|
|
# ---- Assistant Légal Groq (/api/assistant) ---------------
|
|
location /api/assistant {
|
|
# Restriction stricte aux méthodes POST et OPTIONS
|
|
limit_except POST OPTIONS {
|
|
deny all;
|
|
}
|
|
|
|
proxy_pass http://127.0.0.1:8085;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Connection "";
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
|
add_header Cache-Control "no-store, no-cache, must-revalidate";
|
|
add_header X-Content-Type-Options nosniff;
|
|
}
|
|
|
|
# ---- Divers ---------------------------------------------
|
|
add_header X-Content-Type-Options nosniff;
|
|
add_header Referrer-Policy strict-origin-when-cross-origin;
|
|
server_tokens off;
|
|
}
|
|
|