182eae1e36
This fixes the blank page on the base URL by normalizing the no-trailing-slash path in nginx and redirecting unauthenticated users to /login before React mounts.
88 lines
2.6 KiB
Nginx Configuration File
88 lines
2.6 KiB
Nginx Configuration File
# Nginx del contenedor frontend (HTTP interno, puerto 80 → publicado en 8069 en Sinbad2).
|
|
#
|
|
# Flujo HTTPS (igual que orcid2sword en Sinbad2):
|
|
# 1. Usuario → https://sinbad2.ujaen.es/generadorexamenesllm/
|
|
# 2. Apache termina TLS y hace ProxyPass al puerto 8069 (HTTP).
|
|
# 3. Con ProxyPass ... http://host:8069/ Apache QUITA el prefijo /generadorexamenesllm
|
|
# y el contenedor recibe /, /assets/, /auth/, etc.
|
|
# 4. Acceso directo al puerto 8069 (sin Apache) usa el prefijo /generadorexamenesllm/
|
|
# porque el build de Vite lleva VITE_APP_BASE_PATH=/generadorexamenesllm/
|
|
|
|
map $http_x_forwarded_proto $forwarded_proto {
|
|
default $http_x_forwarded_proto;
|
|
"" $scheme;
|
|
}
|
|
|
|
map $http_x_forwarded_host $forwarded_host {
|
|
default $http_x_forwarded_host;
|
|
"" $host;
|
|
}
|
|
|
|
server {
|
|
listen 80;
|
|
server_name _;
|
|
root /usr/share/nginx/html;
|
|
index index.html;
|
|
|
|
gzip on;
|
|
gzip_types text/css application/javascript application/json image/svg+xml;
|
|
gzip_min_length 1024;
|
|
|
|
# --- API: rutas sin prefijo (Apache quita /generadorexamenesllm) ---
|
|
location /auth/ {
|
|
proxy_pass http://backend:8074/auth/;
|
|
include /etc/nginx/snippets/proxy_params.conf;
|
|
}
|
|
|
|
location /exam/ {
|
|
proxy_pass http://backend:8074/exam/;
|
|
include /etc/nginx/snippets/proxy_params.conf;
|
|
}
|
|
|
|
location = /health {
|
|
proxy_pass http://backend:8074/health;
|
|
include /etc/nginx/snippets/proxy_params.conf;
|
|
}
|
|
|
|
location /assets/ {
|
|
expires 1y;
|
|
add_header Cache-Control "public, immutable";
|
|
try_files $uri =404;
|
|
}
|
|
|
|
# Raíz sin barra final → login (evita pantalla en blanco por basename)
|
|
location = /generadorexamenesllm {
|
|
return 301 /generadorexamenesllm/login;
|
|
}
|
|
|
|
location / {
|
|
try_files $uri $uri/ /index.html;
|
|
}
|
|
|
|
# --- Mismo contenido/API bajo prefijo público (acceso directo :8069 o si Apache no quita prefijo) ---
|
|
location ^~ /generadorexamenesllm/auth/ {
|
|
proxy_pass http://backend:8074/auth/;
|
|
include /etc/nginx/snippets/proxy_params.conf;
|
|
}
|
|
|
|
location ^~ /generadorexamenesllm/exam/ {
|
|
proxy_pass http://backend:8074/exam/;
|
|
include /etc/nginx/snippets/proxy_params.conf;
|
|
}
|
|
|
|
location = /generadorexamenesllm/health {
|
|
proxy_pass http://backend:8074/health;
|
|
include /etc/nginx/snippets/proxy_params.conf;
|
|
}
|
|
|
|
location ^~ /generadorexamenesllm/assets/ {
|
|
alias /usr/share/nginx/html/assets/;
|
|
expires 1y;
|
|
add_header Cache-Control "public, immutable";
|
|
}
|
|
|
|
location ^~ /generadorexamenesllm/ {
|
|
try_files $uri $uri/ /index.html;
|
|
}
|
|
}
|