DeutschLernen/german-app-frontend/nginx.conf
Lasse Rune Hansen ab811dc851 fix(frontend/nginx): Add /audio/ proxy and fix /api/ proxy to backend
- Fixed nginx proxy for /api/ to include /api/ prefix (backend expects it)
- Added /audio/ proxy to backend for audio file serving
- Backend serves audio from wwwroot/audio/story/

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-06-14 08:00:25 +02:00

51 lines
1.5 KiB
Nginx Configuration File

server {
listen 3000;
server_name localhost;
# Root directory
root /usr/share/nginx/html;
index index.html;
# Handle React Router - return index.html for all requests
location / {
try_files $uri $uri/ /index.html;
}
# API proxy to backend (when running in Docker Compose)
# Note: backend expects /api/ prefix, so we proxy /api/ -> http://backend:8080/api/
location /api/ {
proxy_pass http://backend:8080/api/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# Audio files proxy to backend (served from wwwroot/audio/)
location /audio/ {
proxy_pass http://backend:8080/audio/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# Health check endpoint
location /health {
access_log off;
return 200 "healthy\n";
add_header Content-Type text/plain;
}
# Error pages
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# Cache static assets
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
}