11worker_processes auto;
22
33events {
4- worker_connections 1024;
4+ worker_connections 4096;
5+ multi_accept on;
56}
67
78http {
89 resolver ${DNS_RESOLVER} valid=30s;
910 resolver_timeout 5s;
11+ keepalive_timeout 65s;
12+ keepalive_requests 10000;
1013
1114 upstream owlery {
1215 server ${UPSTREAM_SERVER};
@@ -31,9 +34,11 @@ http {
3134 proxy_cache_valid 200 7776000s;
3235 proxy_cache_valid 404 600s;
3336
34- proxy_cache_use_stale updating;
37+ proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504 http_404 ;
3538 proxy_cache_background_update on;
3639 proxy_cache_lock on;
40+ proxy_cache_lock_timeout 30s;
41+ proxy_cache_lock_age 120s;
3742
3843 server {
3944 listen 80;
@@ -57,16 +62,18 @@ http {
5762 proxy_buffering on;
5863 proxy_http_version 1.1;
5964 proxy_set_header Connection "";
60- proxy_connect_timeout 6h;
65+ # Fail fast when the upstream is unreachable; long-running work is in read/send.
66+ proxy_connect_timeout 5s;
6167 proxy_read_timeout 6h;
6268 proxy_send_timeout 6h;
69+ proxy_socket_keepalive on;
6370 proxy_set_header Host $http_host;
6471 proxy_set_header X-Real-IP $remote_addr;
6572 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
6673 proxy_set_header X-Forwarded-Proto $scheme;
6774 proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
68- proxy_next_upstream_timeout 30s ;
69- proxy_next_upstream_tries 2 ;
75+ proxy_next_upstream_timeout 20s ;
76+ proxy_next_upstream_tries 3 ;
7077 add_header X-Cache-Status $upstream_cache_status;
7178 add_header X-Cache-Key "$request_method$request_uri";
7279 proxy_ignore_headers Cache-Control Expires Set-Cookie;
@@ -96,16 +103,18 @@ http {
96103 proxy_buffering on;
97104 proxy_http_version 1.1;
98105 proxy_set_header Connection "";
99- proxy_connect_timeout 6h;
106+ # Fail fast when the upstream is unreachable; long-running work is in read/send.
107+ proxy_connect_timeout 5s;
100108 proxy_read_timeout 6h;
101109 proxy_send_timeout 6h;
110+ proxy_socket_keepalive on;
102111 proxy_set_header Host $http_host;
103112 proxy_set_header X-Real-IP $remote_addr;
104113 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
105114 proxy_set_header X-Forwarded-Proto $scheme;
106115 proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
107- proxy_next_upstream_timeout 30s ;
108- proxy_next_upstream_tries 2 ;
116+ proxy_next_upstream_timeout 20s ;
117+ proxy_next_upstream_tries 3 ;
109118 add_header X-Cache-Status $upstream_cache_status;
110119 add_header X-Cache-Key "$request_method$request_uri";
111120 proxy_ignore_headers Cache-Control Expires Set-Cookie;
0 commit comments