mirror of
https://github.com/MrUnknownDE/bierkasten-casino.git
synced 2026-04-19 14:53:45 +02:00
Vereinfache die Backend-Routen-Konfiguration in NGINX, um alle API-Pfade in einem Block zusammenzufassen und verbessere die Cookie-Header-Weiterleitung.
This commit is contained in:
@@ -9,79 +9,37 @@ server {
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
# --- Backend-Routen: an Node-Backend weiterleiten ---
|
||||
location /health {
|
||||
# --- Backend-Routen: Alle API-Pfade in einem Block zusammenfassen ---
|
||||
# Dies ist sauberer und stellt sicher, dass alle die gleiche Konfiguration verwenden.
|
||||
location ~ ^/(api|auth|me|wallet|slot|admin|health)/ {
|
||||
proxy_pass http://bierbaron_backend;
|
||||
proxy_http_version 1.1;
|
||||
|
||||
# Wichtige Header für die korrekte Funktionsweise hinter einem Proxy
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection 'upgrade';
|
||||
proxy_set_header Host $host;
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
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;
|
||||
|
||||
# --- DIE ENTSCHEIDENDE KORREKTUR ---
|
||||
# Dieser Befehl zwingt NGINX, den Cookie-Header des Clients
|
||||
# explizit an das Backend weiterzuleiten.
|
||||
proxy_set_header Cookie $http_cookie;
|
||||
}
|
||||
|
||||
location /auth/ {
|
||||
proxy_pass http://bierbaron_backend;
|
||||
proxy_http_version 1.1;
|
||||
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;
|
||||
}
|
||||
|
||||
location /api/ {
|
||||
proxy_pass http://bierbaron_backend;
|
||||
proxy_http_version 1.1;
|
||||
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;
|
||||
}
|
||||
|
||||
location /wallet {
|
||||
proxy_pass http://bierbaron_backend;
|
||||
proxy_http_version 1.1;
|
||||
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;
|
||||
}
|
||||
|
||||
location /slot/ {
|
||||
proxy_pass http://bierbaron_backend;
|
||||
proxy_http_version 1.1;
|
||||
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;
|
||||
}
|
||||
|
||||
location /me {
|
||||
proxy_pass http://bierbaron_backend;
|
||||
proxy_http_version 1.1;
|
||||
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;
|
||||
}
|
||||
|
||||
location /admin/ {
|
||||
proxy_pass http://bierbaron_backend;
|
||||
proxy_http_version 1.1;
|
||||
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;
|
||||
}
|
||||
|
||||
# --- Statisches Frontend (SPA) ---
|
||||
# --- Statisches Frontend (Single Page Application) ---
|
||||
# Dieser Block fängt alle Anfragen ab, die nicht zur API gehören.
|
||||
location / {
|
||||
try_files $uri /index.html;
|
||||
}
|
||||
|
||||
# Optionale Caching-Regeln für Assets
|
||||
# Optionale Caching-Regeln für statische Assets
|
||||
location ~* \.(js|css|png|jpg|jpeg|gif|svg|ico|webp|woff|woff2|ttf)$ {
|
||||
expires 7d;
|
||||
add_header Cache-Control "public, max-age=604800, immutable";
|
||||
try_files $uri /index.html;
|
||||
try_files $uri =404; # Gib 404 zurück, wenn Asset nicht gefunden wird
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user