mirror of
https://github.com/ceratic/project_vollidioten_website.git
synced 2026-05-14 00:16:47 +02:00
55 lines
1.5 KiB
Nginx Configuration File
55 lines
1.5 KiB
Nginx Configuration File
server {
|
|
listen 80;
|
|
server_name localhost;
|
|
|
|
root /usr/share/nginx/html;
|
|
index index.html;
|
|
|
|
location / {
|
|
try_files $uri $uri/ /index.html;
|
|
}
|
|
|
|
location /api/ {
|
|
# Try to proxy to backend first
|
|
proxy_pass http://backend:3000;
|
|
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;
|
|
|
|
# Allow larger file uploads (50MB)
|
|
client_max_body_size 50M;
|
|
|
|
# If backend is unavailable, serve mock data
|
|
error_page 502 503 504 = @fallback;
|
|
}
|
|
|
|
location @fallback {
|
|
# Serve mock data from frontend
|
|
rewrite ^/api/(.*)$ /mock/$1 break;
|
|
try_files $uri /index.html;
|
|
|
|
# Add header to indicate mock data is being used
|
|
add_header X-Mock-Data "true";
|
|
add_header X-Backend-Status "unavailable";
|
|
}
|
|
|
|
# Handle auth endpoints
|
|
location /auth/ {
|
|
proxy_pass http://backend:3000;
|
|
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;
|
|
|
|
# Auth endpoints should fail if backend is down
|
|
error_page 502 503 504 = /auth-unavailable.html;
|
|
}
|
|
|
|
# Handle static assets
|
|
location /assets/ {
|
|
expires 1y;
|
|
add_header Cache-Control "public";
|
|
}
|
|
}
|