codigo0/frontend/nginx.conf

45 lines
1.3 KiB
Nginx Configuration File
Raw Normal View History

server {
listen 9112;
server_name _;
root /usr/share/nginx/html;
index index.html;
# Gzip compression
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_types text/plain text/css text/xml application/json application/javascript application/xml+rss application/atom+xml image/svg+xml;
# Cache estatic assets (JS/CSS/fonts)
location ~* \.(js|css|woff2?|ttf|otf|eot|svg|ico|png|jpg|jpeg|webp)$ {
expires 1y;
add_header Cache-Control "public, immutable";
try_files $uri =404;
}
# Cache YAMLs de protocolos (corta duración para poder actualizarlos)
location /protocols/ {
expires 1d;
add_header Cache-Control "public, must-revalidate";
try_files $uri =404;
}
# PWA: manifest y service worker sin caché
location ~* (manifest\.json|sw\.js)$ {
expires off;
add_header Cache-Control "no-cache, no-store, must-revalidate";
try_files $uri =404;
}
# SPA fallback — todas las rutas sirven index.html
location / {
try_files $uri $uri/ /index.html;
}
# Seguridad básica
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
add_header X-XSS-Protection "1; mode=block";
add_header Referrer-Policy "strict-origin-when-cross-origin";
}