fix: nginx
Signed-off-by: Omar Sánchez Pizarro <omar.sanchez@pistacero.net>
This commit is contained in:
@@ -47,6 +47,7 @@ nginx dashboard → /usr/share/nginx/html/dashboard/assets/index-abc123.js
|
|||||||
|
|
||||||
- **Astro config**: Sin base (raíz por defecto)
|
- **Astro config**: Sin base (raíz por defecto)
|
||||||
- **Nginx interno**: Sirve desde `/usr/share/nginx/html/`
|
- **Nginx interno**: Sirve desde `/usr/share/nginx/html/`
|
||||||
|
- **Nginx config**: `web/landing/nginx.conf`
|
||||||
- **Assets**: Se construyen para la raíz
|
- **Assets**: Se construyen para la raíz
|
||||||
|
|
||||||
**Flujo de peticiones**:
|
**Flujo de peticiones**:
|
||||||
@@ -58,6 +59,15 @@ nginx proxy → http://landing:80/
|
|||||||
nginx landing → /usr/share/nginx/html/index.html
|
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
|
## Puertos
|
||||||
|
|
||||||
### Desarrollo local
|
### Desarrollo local
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
server {
|
server {
|
||||||
listen 80;
|
listen 80;
|
||||||
server_name localhost;
|
server_name localhost;
|
||||||
root /usr/share/nginx/html;
|
root /usr/share/nginx/html/dashboard;
|
||||||
index index.html;
|
index index.html;
|
||||||
|
|
||||||
# Gzip compression
|
# Gzip compression
|
||||||
@@ -10,22 +10,16 @@ server {
|
|||||||
gzip_min_length 1024;
|
gzip_min_length 1024;
|
||||||
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml+rss application/json application/javascript;
|
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/
|
# Cache static assets ANTES de SPA routing
|
||||||
location /dashboard/ {
|
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
||||||
# Cache static assets
|
expires 1y;
|
||||||
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
add_header Cache-Control "public, immutable";
|
||||||
expires 1y;
|
try_files $uri =404;
|
||||||
add_header Cache-Control "public, immutable";
|
|
||||||
try_files $uri =404;
|
|
||||||
}
|
|
||||||
|
|
||||||
# SPA routing - todas las rutas del dashboard
|
|
||||||
try_files $uri $uri/ /dashboard/index.html;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Redirigir raíz al dashboard
|
# SPA routing - todo desde la raíz del contenedor
|
||||||
location = / {
|
location / {
|
||||||
return 301 /dashboard/;
|
try_files $uri $uri/ /index.html;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
server {
|
server {
|
||||||
listen 80;
|
listen 80;
|
||||||
server_name localhost;
|
server_name localhost;
|
||||||
root /usr/share/nginx/html;
|
root /usr/share/nginx/html/dashboard;
|
||||||
index index.html;
|
index index.html;
|
||||||
|
|
||||||
# Gzip compression
|
# Gzip compression
|
||||||
@@ -10,22 +10,16 @@ server {
|
|||||||
gzip_min_length 1024;
|
gzip_min_length 1024;
|
||||||
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml+rss application/json application/javascript;
|
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/
|
# Cache static assets ANTES de SPA routing
|
||||||
location /dashboard/ {
|
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
||||||
# Cache static assets
|
expires 1y;
|
||||||
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
add_header Cache-Control "public, immutable";
|
||||||
expires 1y;
|
try_files $uri =404;
|
||||||
add_header Cache-Control "public, immutable";
|
|
||||||
try_files $uri =404;
|
|
||||||
}
|
|
||||||
|
|
||||||
# SPA routing - todas las rutas del dashboard
|
|
||||||
try_files $uri $uri/ /dashboard/index.html;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Redirigir raíz al dashboard
|
# SPA routing - todo desde la raíz del contenedor
|
||||||
location = / {
|
location / {
|
||||||
return 301 /dashboard/;
|
try_files $uri $uri/ /index.html;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,9 @@ FROM nginx:alpine
|
|||||||
# Copiar archivos construidos a la raíz
|
# Copiar archivos construidos a la raíz
|
||||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
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
|
# Exponer puerto
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
|
|||||||
25
web/landing/nginx.conf
Normal file
25
web/landing/nginx.conf
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -33,8 +33,11 @@ server {
|
|||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Dashboard Vue - pasar petición completa con prefijo /dashboard
|
# Dashboard Vue - reescribir /dashboard/* a /* en el contenedor
|
||||||
location /dashboard {
|
location /dashboard/ {
|
||||||
|
# Quitar el prefijo /dashboard antes de pasar al contenedor
|
||||||
|
rewrite ^/dashboard/?(.*)$ /$1 break;
|
||||||
|
|
||||||
proxy_pass http://dashboard:80;
|
proxy_pass http://dashboard:80;
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
|
|||||||
Reference in New Issue
Block a user