docloud.es/nginx.conf

57 lines
1.6 KiB
Nginx Configuration File
Raw Normal View History

server {
listen 80;
server_name localhost;
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 text/javascript application/javascript application/json application/xml image/svg+xml;
# Health check endpoint para monitorización
location = /health {
access_log off;
add_header Content-Type text/plain;
return 200 'OK';
}
# robots.txt - servir directamente
location = /robots.txt {
default_type text/plain;
try_files $uri =404;
}
# sitemap.xml - servir directamente
location = /sitemap.xml {
default_type application/xml;
try_files $uri =404;
}
# Cache para assets estaticos (1 año)
location ~* \.(css|js|jpg|jpeg|png|gif|ico|svg|woff|woff2|ttf|eot)$ {
expires 1y;
add_header Cache-Control "public, immutable";
access_log off;
}
# Cache para HTML (5 minutos)
location ~* \.html$ {
expires 5m;
add_header Cache-Control "public, must-revalidate";
}
# SPA fallback (solo para rutas que no existen)
location / {
try_files $uri $uri/ $uri/index.html /index.html;
}
# Security headers
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
add_header Permissions-Policy "geolocation=(), microphone=(), camera=()" always;
}