feat: enhance Nginx configuration and API error handling
- Updated Nginx configuration to improve service dependency resolution and proxying for API and media requests. - Added a resolver directive to mitigate sporadic 502 errors related to backend container IP changes. - Enhanced error handling in the API utility to provide clearer feedback for various HTTP errors, including specific guidance for 502 Bad Gateway responses.
This commit is contained in:
1 parent
60132e97e8
commit
d67026e25a
2 files changed
+28
-5
No files matched your search
+10
-3
@@ -4,12 +4,17 @@ server {
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
# Docker-Embedded DNS: Hostname »backend« bei Container-Neustarts neu auflösen
|
||||
# — verringert sporadische 502, wenn sich nur die Backend-Container-IP geändert hat.
|
||||
resolver 127.0.0.11 valid=10s ipv6=off;
|
||||
|
||||
# Uploads (Übungsmedien) und API erreichen Clients unter derselben Host-URL wie die SPA —
|
||||
# dafür muss Nginx zur FastAPI-Instanz im Compose-Netz weiterleiten.
|
||||
client_max_body_size 64m;
|
||||
|
||||
location ^~ /api/ {
|
||||
proxy_pass http://backend:8000;
|
||||
set $docker_backend_svc backend;
|
||||
proxy_pass http://$docker_backend_svc:8000$request_uri;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
@@ -21,7 +26,8 @@ server {
|
||||
}
|
||||
|
||||
location ^~ /media/ {
|
||||
proxy_pass http://backend:8000;
|
||||
set $docker_backend_svc backend;
|
||||
proxy_pass http://$docker_backend_svc:8000$request_uri;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
@@ -30,7 +36,8 @@ server {
|
||||
}
|
||||
|
||||
location = /health {
|
||||
proxy_pass http://backend:8000/health;
|
||||
set $hc_upstream backend;
|
||||
proxy_pass http://$hc_upstream:8000/health;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user