35
35
'"upstream_http_location":"$upstream_http_location ",'
36
36
'"upstream_cache_status":"$upstream_cache_status ",'
37
37
'"http_authorization":"$http_authorization ",'
38
- '}' ;
39
-
38
+ '}' ;
39
+
40
40
log_format debug_proxy escape=json
41
41
'{'
42
42
'"access_time":"$time_local ",'
@@ -56,20 +56,22 @@ http {
56
56
'"upstream_http_location":"$upstream_http_location ",'
57
57
'"upstream_cache_status":"$upstream_cache_status ",'
58
58
'"http_authorization":"$http_authorization ",'
59
- '}' ;
60
-
59
+ '}' ;
60
+
61
61
log_format tweaked escape=json
62
62
'{'
63
63
'"access_time":"$time_local ",'
64
64
'"upstream_cache_status":"$upstream_cache_status ",'
65
+ '"method":"$request_method ",'
65
66
'"uri":"$uri ",'
66
67
'"status":"$status ",'
67
68
'"bytes_sent":"$body_bytes_sent ",'
69
+ '"upstream_response_time":"$upstream_response_time ",'
68
70
'"host":"$host ",'
69
71
'"proxy_host":"$proxy_host ",'
70
72
'"upstream":"$upstream_addr "'
71
73
'}' ;
72
-
74
+
73
75
keepalive_timeout 300 ;
74
76
gzip off ;
75
77
@@ -199,6 +201,9 @@ echo "Docker configured with HTTPS_PROXY=$scheme://$http_host/"
199
201
# Do some tweaked logging.
200
202
access_log /var/log/nginx/access.log tweaked;
201
203
204
+ # Send upstream status as header
205
+ add_header X-Docker-Registry-Proxy-Cache-Upstream-Status "$upstream_cache_status " ;
206
+
202
207
# Use the generated certificates, they contain names for all the proxied registries.
203
208
ssl_certificate /certs/fullchain.pem;
204
209
ssl_certificate_key /certs/web.key;
@@ -263,18 +268,20 @@ echo "Docker configured with HTTPS_PROXY=$scheme://$http_host/"
263
268
proxy_intercept_errors on ;
264
269
error_page 301 302 307 = @handle_redirects;
265
270
}
266
-
271
+
267
272
# For manifest requests by digest, do cache, and treat redirects.
273
+ # These are some of the requests that DockerHub will throttle.
268
274
location ~ ^/v2/(.*)/manifests/sha256:(.*) {
269
275
proxy_pass https://$targetHost ;
270
276
proxy_cache cache;
271
277
proxy_cache_key $uri ;
272
278
proxy_intercept_errors on ;
273
279
error_page 301 302 307 = @handle_redirects;
274
280
}
275
-
281
+
276
282
# Cache manifest requests that are not by digest (e.g. tags)
277
283
# Since these are mutable, we invalidate them immediately and keep them only in case the backend is down
284
+ # These are some of the requests that DockerHub will throttle.
278
285
location ~ ^/v2/(.*)/manifests/ {
279
286
proxy_pass https://$targetHost ;
280
287
proxy_cache cache;
@@ -284,7 +291,7 @@ echo "Docker configured with HTTPS_PROXY=$scheme://$http_host/"
284
291
proxy_cache_valid 1s ;
285
292
error_page 301 302 307 = @handle_redirects;
286
293
}
287
-
294
+
288
295
# Cache blobs requests that are not by digest
289
296
# Since these are mutable, we invalidate them immediately and keep them only in case the backend is down
290
297
location ~ ^/v2/(.*)/blobs/ {
@@ -296,7 +303,7 @@ echo "Docker configured with HTTPS_PROXY=$scheme://$http_host/"
296
303
proxy_cache_valid 1s ;
297
304
error_page 301 302 307 = @handle_redirects;
298
305
}
299
-
306
+
300
307
location @handle_redirects {
301
308
#store the current state of the world so we can reuse it in a minute
302
309
# We need to capture these values now, because as soon as we invoke
@@ -322,7 +329,6 @@ echo "Docker configured with HTTPS_PROXY=$scheme://$http_host/"
322
329
location / {
323
330
proxy_pass https://$targetHost ;
324
331
proxy_cache off ;
325
- add_header X-Docker-Caching-Proxy-Debug-Cache "no:default" ;
326
332
}
327
333
}
328
334
}
0 commit comments