Skip to content

Commit ffc7540

Browse files
committed
add request method and upstream time to logging; add cache status header; helps investigate #54
1 parent 78f96ff commit ffc7540

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

nginx.conf

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ http {
3535
'"upstream_http_location":"$upstream_http_location",'
3636
'"upstream_cache_status":"$upstream_cache_status",'
3737
'"http_authorization":"$http_authorization",'
38-
'}';
39-
38+
'}';
39+
4040
log_format debug_proxy escape=json
4141
'{'
4242
'"access_time":"$time_local",'
@@ -56,20 +56,22 @@ http {
5656
'"upstream_http_location":"$upstream_http_location",'
5757
'"upstream_cache_status":"$upstream_cache_status",'
5858
'"http_authorization":"$http_authorization",'
59-
'}';
60-
59+
'}';
60+
6161
log_format tweaked escape=json
6262
'{'
6363
'"access_time":"$time_local",'
6464
'"upstream_cache_status":"$upstream_cache_status",'
65+
'"method":"$request_method",'
6566
'"uri":"$uri",'
6667
'"status":"$status",'
6768
'"bytes_sent":"$body_bytes_sent",'
69+
'"upstream_response_time":"$upstream_response_time",'
6870
'"host":"$host",'
6971
'"proxy_host":"$proxy_host",'
7072
'"upstream":"$upstream_addr"'
7173
'}';
72-
74+
7375
keepalive_timeout 300;
7476
gzip off;
7577

@@ -199,6 +201,9 @@ echo "Docker configured with HTTPS_PROXY=$scheme://$http_host/"
199201
# Do some tweaked logging.
200202
access_log /var/log/nginx/access.log tweaked;
201203

204+
# Send upstream status as header
205+
add_header X-Docker-Registry-Proxy-Cache-Upstream-Status "$upstream_cache_status";
206+
202207
# Use the generated certificates, they contain names for all the proxied registries.
203208
ssl_certificate /certs/fullchain.pem;
204209
ssl_certificate_key /certs/web.key;
@@ -263,18 +268,20 @@ echo "Docker configured with HTTPS_PROXY=$scheme://$http_host/"
263268
proxy_intercept_errors on;
264269
error_page 301 302 307 = @handle_redirects;
265270
}
266-
271+
267272
# For manifest requests by digest, do cache, and treat redirects.
273+
# These are some of the requests that DockerHub will throttle.
268274
location ~ ^/v2/(.*)/manifests/sha256:(.*) {
269275
proxy_pass https://$targetHost;
270276
proxy_cache cache;
271277
proxy_cache_key $uri;
272278
proxy_intercept_errors on;
273279
error_page 301 302 307 = @handle_redirects;
274280
}
275-
281+
276282
# Cache manifest requests that are not by digest (e.g. tags)
277283
# 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.
278285
location ~ ^/v2/(.*)/manifests/ {
279286
proxy_pass https://$targetHost;
280287
proxy_cache cache;
@@ -284,7 +291,7 @@ echo "Docker configured with HTTPS_PROXY=$scheme://$http_host/"
284291
proxy_cache_valid 1s;
285292
error_page 301 302 307 = @handle_redirects;
286293
}
287-
294+
288295
# Cache blobs requests that are not by digest
289296
# Since these are mutable, we invalidate them immediately and keep them only in case the backend is down
290297
location ~ ^/v2/(.*)/blobs/ {
@@ -296,7 +303,7 @@ echo "Docker configured with HTTPS_PROXY=$scheme://$http_host/"
296303
proxy_cache_valid 1s;
297304
error_page 301 302 307 = @handle_redirects;
298305
}
299-
306+
300307
location @handle_redirects {
301308
#store the current state of the world so we can reuse it in a minute
302309
# 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/"
322329
location / {
323330
proxy_pass https://$targetHost;
324331
proxy_cache off;
325-
add_header X-Docker-Caching-Proxy-Debug-Cache "no:default";
326332
}
327333
}
328334
}

0 commit comments

Comments
 (0)