The previous regex routed all methods for /login to the backend. A browser navigating to /login sends GET, which returned 405 because the backend only has POST /login. Now GET goes to the React SPA. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
72 lines
1.9 KiB
Nginx Configuration File
72 lines
1.9 KiB
Nginx Configuration File
worker_processes auto;
|
|
error_log /var/log/nginx/error.log warn;
|
|
|
|
events {
|
|
worker_connections 1024;
|
|
}
|
|
|
|
http {
|
|
include /etc/nginx/mime.types;
|
|
default_type application/octet-stream;
|
|
sendfile on;
|
|
keepalive_timeout 65;
|
|
client_max_body_size 100M;
|
|
|
|
upstream backend {
|
|
server backend:8000;
|
|
}
|
|
|
|
upstream frontend {
|
|
server frontend:80;
|
|
}
|
|
|
|
server {
|
|
listen 80;
|
|
|
|
# API + HLS + ping: immer Backend
|
|
location ~ ^/(api|hls|ping)(/.*)?$ {
|
|
proxy_pass http://backend;
|
|
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_read_timeout 300s;
|
|
proxy_buffering off;
|
|
}
|
|
|
|
# POST /login → Backend (ABS-API), GET /login → Frontend (React SPA)
|
|
location = /login {
|
|
if ($request_method = POST) {
|
|
proxy_pass http://backend;
|
|
}
|
|
proxy_pass http://frontend;
|
|
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_read_timeout 300s;
|
|
}
|
|
|
|
# POST /logout → Backend
|
|
location = /logout {
|
|
if ($request_method = POST) {
|
|
proxy_pass http://backend;
|
|
}
|
|
proxy_pass http://frontend;
|
|
proxy_set_header Host $host;
|
|
}
|
|
|
|
# Cover images
|
|
location /covers/ {
|
|
proxy_pass http://backend;
|
|
proxy_set_header Host $host;
|
|
expires 7d;
|
|
add_header Cache-Control "public";
|
|
}
|
|
|
|
# Frontend (React SPA) — alle anderen Routen
|
|
location / {
|
|
proxy_pass http://frontend;
|
|
proxy_set_header Host $host;
|
|
}
|
|
}
|
|
}
|