@@ -252,6 +252,9 @@ echo "Docker configured with HTTPS_PROXY=$scheme://$http_host/"
252252 proxy_ignore_client_abort on;
253253 proxy_cache_revalidate on;
254254
255+ # Avoid conversion of HEAD method to GET
256+ proxy_cache_convert_head off;
257+
255258 # Hide/ignore headers from caching. S3 especially likes to send Expires headers in the past in some situations.
256259 proxy_hide_header Set-Cookie;
257260 proxy_ignore_headers X-Accel-Expires Expires Cache-Control Set-Cookie;
@@ -275,15 +278,15 @@ echo "Docker configured with HTTPS_PROXY=$scheme://$http_host/"
275278 # For blob requests by digest, do cache, and treat redirects.
276279 location ~ ^/v2/( .*) /blobs/sha256:( .*) {
277280 set $docker_proxy_request_type "blob-by-digest" ;
278- set $cache_key $2 ;
281+ set $cache_key $request_method$ 2 ;
279282 include "/etc/nginx/nginx.manifest.common.conf" ;
280283 }
281284
282285 # For manifest requests by digest, do cache, and treat redirects.
283286 # These are some of the requests that DockerHub will throttle.
284287 location ~ ^/v2/( .*) /manifests/sha256:( .*) {
285288 set $docker_proxy_request_type "manifest-by-digest" ;
286- set $cache_key $uri ;
289+ set $cache_key $request_method$ uri ;
287290 include "/etc/nginx/nginx.manifest.common.conf" ;
288291 }
289292
@@ -296,7 +299,7 @@ echo "Docker configured with HTTPS_PROXY=$scheme://$http_host/"
296299 # Since these are mutable, we invalidate them immediately and keep them only in case the backend is down
297300 location ~ ^/v2/( .*) /blobs/ {
298301 set $docker_proxy_request_type "blob-mutable" ;
299- set $cache_key $uri ;
302+ set $cache_key $request_method$ uri ;
300303 proxy_cache_valid 0s ;
301304 include "/etc/nginx/nginx.manifest.stale.conf" ;
302305 }
@@ -307,6 +310,7 @@ echo "Docker configured with HTTPS_PROXY=$scheme://$http_host/"
307310 # the proxy_* directives, these will disappear
308311 set $original_uri $uri ;
309312 set $orig_loc $upstream_http_location ;
313+ set $orig_cache_key $cache_key
310314 # Handle relative re-direct in Location header (as opposed to absolute)
311315 if ( $upstream_http_location !~ "^http" ) {
312316 set $orig_loc "${scheme}://${host}${upstream_http_location}" ;
@@ -322,7 +326,7 @@ echo "Docker configured with HTTPS_PROXY=$scheme://$http_host/"
322326 proxy_cache $cache ;
323327 # But we store the result with the cache key of the original request URI
324328 # so that future clients don't need to follow the redirect too
325- proxy_cache_key $original_uri $slice_range ;
329+ proxy_cache_key $orig_cache_key $slice_range ;
326330 }
327331
328332 # by default, dont cache anything.
0 commit comments