# --------------------------------------------------------------------------- # Config de nginx para el sitio estático de Collina. # Se copia a /etc/nginx/conf.d/default.conf (reemplaza el server por defecto). # # Cache-Control se deriva del Content-Type con un map, para mantener TODOS los # add_header en un solo ámbito (server). Motivo: en nginx, si un `location` # define su propio add_header, PIERDE los add_header heredados del server # (las cabeceras de seguridad desaparecerían en html/assets). Con este enfoque # no hay location anidada con headers -> nada se pierde. # --------------------------------------------------------------------------- map $sent_http_content_type $cache_control { default "no-cache"; # HTML y desconocidos: siempre revalidar ~*text/html "no-cache"; ~*image/ "public, max-age=31536000, immutable"; # webp/png/jpg/svg ~*video/ "public, max-age=31536000, immutable"; # mp4 ~*font/ "public, max-age=31536000, immutable"; ~*text/css "public, max-age=31536000, immutable"; ~*application/javascript "public, max-age=31536000, immutable"; ~*application/pdf "public, max-age=604800"; # PDF: 1 semana } # ---- Redirect 301 permanente: collinasystems.com -> collinasystems.com.mx (canónico) ---- # $request_uri conserva ruta + query string. Coolify/Traefik termina el TLS antes de # nginx, por eso escucha en :80 (sin listen 443 ni certificados aquí). server { listen 80; listen [::]:80; server_name collinasystems.com www.collinasystems.com; return 301 https://collinasystems.com.mx$request_uri; } # ---- Sitio canónico (.com.mx). default_server para atender también acceso por IP y # health-checks internos de Coolify (hosts que no matchean ningún server_name). ---- server { listen 80 default_server; listen [::]:80 default_server; server_name collinasystems.com.mx www.collinasystems.com.mx; root /usr/share/nginx/html; index index.html; # ---- Compresión ---- gzip on; gzip_vary on; gzip_comp_level 6; gzip_min_length 256; gzip_proxied any; gzip_types text/plain text/css text/xml application/javascript application/json application/xml image/svg+xml application/rss+xml font/ttf font/otf application/vnd.ms-fontobject; # Nota: gzip NO re-comprime jpg/png/webp/mp4 (ya vienen comprimidos). # brotli daría ~15% adicional pero requiere un módulo que nginx:alpine no trae. # ---- Cabeceras (un solo ámbito -> no se pierden por herencia) ---- add_header X-Content-Type-Options "nosniff" always; add_header X-Frame-Options "SAMEORIGIN" always; add_header Referrer-Policy "strict-origin-when-cross-origin" always; add_header Permissions-Policy "geolocation=(), microphone=(), camera=()" always; add_header Cache-Control $cache_control always; # Sirve archivos tal cual; los nombres con espacios ("Index movil.html") # se resuelven normal vía la URL codificada (Index%20movil.html). location / { try_files $uri $uri/ =404; } }