fix: nginx

Signed-off-by: Omar Sánchez Pizarro <omar.sanchez@pistacero.net>
This commit is contained in:
Omar Sánchez Pizarro
2026-01-21 00:53:52 +01:00
parent 905966d548
commit 3acad140c5
6 changed files with 61 additions and 32 deletions

View File

@@ -47,6 +47,7 @@ nginx dashboard → /usr/share/nginx/html/dashboard/assets/index-abc123.js
- **Astro config**: Sin base (raíz por defecto)
- **Nginx interno**: Sirve desde `/usr/share/nginx/html/`
- **Nginx config**: `web/landing/nginx.conf`
- **Assets**: Se construyen para la raíz
**Flujo de peticiones**:
@@ -58,6 +59,15 @@ nginx proxy → http://landing:80/
nginx landing → /usr/share/nginx/html/index.html
```
**Assets (ej: logo.jpg)**:
```
Usuario → http://localhost/logo.jpg
nginx proxy → http://landing:80/logo.jpg
nginx landing → /usr/share/nginx/html/logo.jpg
```
## Puertos
### Desarrollo local

View File

@@ -1,7 +1,7 @@
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
root /usr/share/nginx/html/dashboard;
index index.html;
# Gzip compression
@@ -10,22 +10,16 @@ server {
gzip_min_length 1024;
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml+rss application/json application/javascript;
# Dashboard assets con prefijo /dashboard/
location /dashboard/ {
# Cache static assets
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
expires 1y;
add_header Cache-Control "public, immutable";
try_files $uri =404;
}
# SPA routing - todas las rutas del dashboard
try_files $uri $uri/ /dashboard/index.html;
# Cache static assets ANTES de SPA routing
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
expires 1y;
add_header Cache-Control "public, immutable";
try_files $uri =404;
}
# Redirigir raíz al dashboard
location = / {
return 301 /dashboard/;
# SPA routing - todo desde la raíz del contenedor
location / {
try_files $uri $uri/ /index.html;
}
}

View File

@@ -1,7 +1,7 @@
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
root /usr/share/nginx/html/dashboard;
index index.html;
# Gzip compression
@@ -10,22 +10,16 @@ server {
gzip_min_length 1024;
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml+rss application/json application/javascript;
# Dashboard assets con prefijo /dashboard/
location /dashboard/ {
# Cache static assets
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
expires 1y;
add_header Cache-Control "public, immutable";
try_files $uri =404;
}
# SPA routing - todas las rutas del dashboard
try_files $uri $uri/ /dashboard/index.html;
# Cache static assets ANTES de SPA routing
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
expires 1y;
add_header Cache-Control "public, immutable";
try_files $uri =404;
}
# Redirigir raíz al dashboard
location = / {
return 301 /dashboard/;
# SPA routing - todo desde la raíz del contenedor
location / {
try_files $uri $uri/ /index.html;
}
}

View File

@@ -20,6 +20,9 @@ FROM nginx:alpine
# Copiar archivos construidos a la raíz
COPY --from=builder /app/dist /usr/share/nginx/html
# Copiar configuración de nginx
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Exponer puerto
EXPOSE 80

25
web/landing/nginx.conf Normal file
View File

@@ -0,0 +1,25 @@
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/x-javascript application/xml+rss application/json application/javascript image/svg+xml;
# Cache static assets
location ~* \.(jpg|jpeg|png|gif|ico|svg|css|js|woff|woff2|ttf|eot)$ {
expires 1y;
add_header Cache-Control "public, immutable";
try_files $uri =404;
}
# Serve static files
location / {
try_files $uri $uri/ /index.html;
}
}

View File

@@ -33,8 +33,11 @@ server {
proxy_set_header X-Forwarded-Proto $scheme;
}
# Dashboard Vue - pasar petición completa con prefijo /dashboard
location /dashboard {
# Dashboard Vue - reescribir /dashboard/* a /* en el contenedor
location /dashboard/ {
# Quitar el prefijo /dashboard antes de pasar al contenedor
rewrite ^/dashboard/?(.*)$ /$1 break;
proxy_pass http://dashboard:80;
proxy_http_version 1.1;
proxy_set_header Host $host;