From 8524e376c1204048e67bd40e135aaa30b9fa77d2 Mon Sep 17 00:00:00 2001 From: Ricardo Pardini Date: Fri, 30 Oct 2020 12:33:41 +0100 Subject: [PATCH] add request_type logging and headers; values are blob-by-digest, manifest-by-digest, manifest-mutable, blob-mutable --- nginx.conf | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/nginx.conf b/nginx.conf index 11debcd..9351073 100644 --- a/nginx.conf +++ b/nginx.conf @@ -64,6 +64,7 @@ http { '"upstream_cache_status":"$upstream_cache_status",' '"method":"$request_method",' '"uri":"$uri",' + '"request_type":"$docker_proxy_request_type",' '"status":"$status",' '"bytes_sent":"$body_bytes_sent",' '"upstream_response_time":"$upstream_response_time",' @@ -135,6 +136,7 @@ http { # dont log the CONNECT proxy. #access_log /var/log/nginx/access.log debug_proxy; access_log off; + set $docker_proxy_request_type "unknown-connect"; proxy_connect; proxy_connect_address $interceptedHost; @@ -201,6 +203,7 @@ echo "Docker configured with HTTPS_PROXY=$scheme://$http_host/" # Do some tweaked logging. access_log /var/log/nginx/access.log tweaked; + set $docker_proxy_request_type "unknown"; # Send upstream status as header add_header X-Docker-Registry-Proxy-Cache-Upstream-Status "$upstream_cache_status"; @@ -263,6 +266,9 @@ echo "Docker configured with HTTPS_PROXY=$scheme://$http_host/" # For blob requests by digest, do cache, and treat redirects. location ~ ^/v2/(.*)/blobs/sha256:(.*) { + set $docker_proxy_request_type "blob-by-digest"; + add_header X-Docker-Registry-Proxy-Cache-Upstream-Status "$upstream_cache_status"; + add_header X-Docker-Registry-Proxy-Cache-Type "$docker_proxy_request_type"; proxy_pass https://$targetHost; proxy_cache cache; proxy_cache_key $uri; @@ -273,6 +279,9 @@ echo "Docker configured with HTTPS_PROXY=$scheme://$http_host/" # For manifest requests by digest, do cache, and treat redirects. # These are some of the requests that DockerHub will throttle. location ~ ^/v2/(.*)/manifests/sha256:(.*) { + set $docker_proxy_request_type "manifest-by-digest"; + add_header X-Docker-Registry-Proxy-Cache-Upstream-Status "$upstream_cache_status"; + add_header X-Docker-Registry-Proxy-Cache-Type "$docker_proxy_request_type"; proxy_pass https://$targetHost; proxy_cache cache; proxy_cache_key $uri; @@ -284,6 +293,9 @@ echo "Docker configured with HTTPS_PROXY=$scheme://$http_host/" # Since these are mutable, we invalidate them immediately and keep them only in case the backend is down # These are some of the requests that DockerHub will throttle. location ~ ^/v2/(.*)/manifests/ { + set $docker_proxy_request_type "manifest-mutable"; + add_header X-Docker-Registry-Proxy-Cache-Upstream-Status "$upstream_cache_status"; + add_header X-Docker-Registry-Proxy-Cache-Type "$docker_proxy_request_type"; proxy_pass https://$targetHost; proxy_cache cache; proxy_cache_key $uri; @@ -296,6 +308,9 @@ echo "Docker configured with HTTPS_PROXY=$scheme://$http_host/" # Cache blobs requests that are not by digest # Since these are mutable, we invalidate them immediately and keep them only in case the backend is down location ~ ^/v2/(.*)/blobs/ { + set $docker_proxy_request_type "blob-mutable"; + add_header X-Docker-Registry-Proxy-Cache-Upstream-Status "$upstream_cache_status"; + add_header X-Docker-Registry-Proxy-Cache-Type "$docker_proxy_request_type"; proxy_pass https://$targetHost; proxy_cache cache; proxy_cache_key $uri;