Skip to content

Commit 5945903

Browse files
fix nginx connections issues
1 parent ea73d30 commit 5945903

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

backend/app/main.py

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
allow_credentials=True,
2222
allow_methods=["GET", "POST"],
2323
allow_headers=["*"],
24+
expose_headers=["Content-Type", "Content-Disposition"],
2425
)
2526

2627
API_ANALYTICS_KEY = os.getenv("API_ANALYTICS_KEY")

backend/nginx/api.conf

+22-6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,28 @@ server {
1515
proxy_pass http://127.0.0.1:8000;
1616
include proxy_params;
1717
proxy_redirect off;
18+
19+
# Add these new settings
20+
proxy_buffering off;
21+
proxy_http_version 1.1;
22+
proxy_set_header Connection '';
23+
proxy_set_header X-Real-IP $remote_addr;
24+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
25+
proxy_set_header Host $host;
26+
27+
# Increase timeouts
28+
proxy_connect_timeout 300;
29+
proxy_send_timeout 300;
30+
proxy_read_timeout 300;
31+
send_timeout 300;
32+
33+
# Add error handling
34+
proxy_next_upstream error timeout http_500 http_502 http_503 http_504;
35+
proxy_next_upstream_tries 2;
36+
37+
# Keep connection alive
38+
keepalive_timeout 300;
39+
keepalive_requests 100;
1840
}
1941

2042
# Return 444 for everything else (no response, just close connection)
@@ -23,12 +45,6 @@ server {
2345
# keep access log on
2446
}
2547

26-
# Add timeout settings
27-
proxy_connect_timeout 300;
28-
proxy_send_timeout 300;
29-
proxy_read_timeout 300;
30-
send_timeout 300;
31-
3248
listen 443 ssl; # managed by Certbot
3349
ssl_certificate /etc/letsencrypt/live/api.gitdiagram.com/fullchain.pem; # managed by Certbot
3450
ssl_certificate_key /etc/letsencrypt/live/api.gitdiagram.com/privkey.pem; # managed by Certbot

0 commit comments

Comments
 (0)