feat(nginx): redirect 301 collinasystems.com -> collinasystems.com.mx
- Nuevo server block: .com y www.com -> 301 permanente a .com.mx (conserva ruta + query string via $request_uri). - El bloque del sitio pasa a server_name explicito (.com.mx / www.com.mx) + default_server, para seguir atendiendo acceso por IP y health-checks de Coolify sin ser redirigido (evita loops / redirect del dominio canonico). - Dockerfile: copia nginx.conf a conf.d (necesario para que el redirect aplique). TLS lo termina Coolify/Traefik antes de nginx (listen :80, sin 443/certs).
This commit is contained in:
1 parent
7c0d72ccb3
commit
15ce316cd1
2 files changed
+78
No files matched your search
@@ -1,3 +1,12 @@
|
|||||||
FROM nginx:alpine
|
FROM nginx:alpine
|
||||||
|
|
||||||
|
# Sitio estático
|
||||||
COPY . /usr/share/nginx/html
|
COPY . /usr/share/nginx/html
|
||||||
|
|
||||||
|
# Config de nginx (gzip + Cache-Control + headers de seguridad)
|
||||||
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
|
||||||
|
# Evita servir la propia config desde el webroot (COPY . también la copió ahí)
|
||||||
|
RUN rm -f /usr/share/nginx/html/nginx.conf
|
||||||
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
+69
@@ -0,0 +1,69 @@
|
|||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user