1+ worker_processes auto;
2+
3+ events {
4+ worker_connections 1024;
5+ }
6+
7+ http {
8+ resolver ${DNS_RESOLVER} valid=30s;
9+ resolver_timeout 5s;
10+
11+ upstream owlery {
12+ server ${UPSTREAM_SERVER};
13+ keepalive 16;
14+ }
15+
16+ log_format cache '$remote_addr - $remote_user [$time_local] "$request" '
17+ '$status $body_bytes_sent "$http_referer" '
18+ '"$http_user_agent" "$http_x_forwarded_for" '
19+ '$upstream_cache_status $request_time $upstream_response_time';
20+
21+ access_log /dev/stdout cache;
22+ error_log /dev/stderr warn;
23+
24+ proxy_cache_path /var/cache/nginx/owlery levels=1:2 keys_zone=owlery_cache:100m max_size=${CACHE_MAX_SIZE} inactive=7776000s use_temp_path=off;
25+
26+ proxy_cache_key "$request_method$request_uri";
27+ proxy_cache_min_uses 1;
28+ proxy_cache_revalidate on;
29+ proxy_cache_methods GET HEAD;
30+
31+ proxy_cache_valid 200 7776000s;
32+ proxy_cache_valid 404 600s;
33+
34+ proxy_cache_use_stale updating;
35+ proxy_cache_background_update on;
36+ proxy_cache_lock on;
37+
38+ server {
39+ listen 80;
40+
41+ location /health {
42+ access_log off;
43+ proxy_pass http://owlery/;
44+ proxy_connect_timeout 3s;
45+ proxy_read_timeout 3s;
46+ proxy_intercept_errors on;
47+ error_page 500 502 503 504 =503 "UPSTREAM_UNAVAILABLE\n";
48+ add_header Content-Type text/plain;
49+ add_header X-Upstream-Status $upstream_status;
50+ }
51+
52+ location / {
53+ proxy_pass http://owlery$request_uri;
54+ proxy_http_version 1.1;
55+ proxy_set_header Connection "";
56+ proxy_connect_timeout 90s;
57+ proxy_read_timeout 90s;
58+ proxy_send_timeout 90s;
59+ proxy_set_header Host $http_host;
60+ proxy_set_header X-Real-IP $remote_addr;
61+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
62+ proxy_set_header X-Forwarded-Proto $scheme;
63+ proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
64+ proxy_next_upstream_timeout 30s;
65+ proxy_next_upstream_tries 2;
66+ add_header X-Cache-Status $upstream_cache_status;
67+ add_header X-Cache-Key "$request_method$request_uri";
68+ proxy_ignore_headers Cache-Control Expires Set-Cookie;
69+ proxy_cache owlery_cache;
70+ }
71+ }
72+
73+ server {
74+ listen 8080;
75+
76+ location /health {
77+ access_log off;
78+ proxy_pass http://owlery/;
79+ proxy_connect_timeout 3s;
80+ proxy_read_timeout 3s;
81+ proxy_intercept_errors on;
82+ error_page 500 502 503 504 =503 "UPSTREAM_UNAVAILABLE\n";
83+ add_header Content-Type text/plain;
84+ add_header X-Upstream-Status $upstream_status;
85+ }
86+
87+ location / {
88+ proxy_pass http://owlery$request_uri;
89+ proxy_http_version 1.1;
90+ proxy_set_header Connection "";
91+ proxy_connect_timeout 90s;
92+ proxy_read_timeout 90s;
93+ proxy_send_timeout 90s;
94+ proxy_set_header Host $http_host;
95+ proxy_set_header X-Real-IP $remote_addr;
96+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
97+ proxy_set_header X-Forwarded-Proto $scheme;
98+ proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
99+ proxy_next_upstream_timeout 30s;
100+ proxy_next_upstream_tries 2;
101+ add_header X-Cache-Status $upstream_cache_status;
102+ add_header X-Cache-Key "$request_method$request_uri";
103+ proxy_ignore_headers Cache-Control Expires Set-Cookie;
104+ proxy_cache owlery_cache;
105+ }
106+ }
107+ }
0 commit comments