Skip to content

Commit 7b3e99a

Browse files
aspettlrpardini
authored andcommitted
Disable conversion of HEAD method to GET
1 parent e3f1eee commit 7b3e99a

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

Diff for: nginx.conf

+11-1
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,16 @@ echo "Docker configured with HTTPS_PROXY=$scheme://$http_host/"
244244
proxy_ignore_client_abort on;
245245
proxy_cache_revalidate on;
246246

247+
# Avoid conversion of HEAD method to GET
248+
proxy_cache_convert_head off;
249+
# HEAD requests are to be cached separately from GET, so they need a different cache key.
250+
# To avoid a breaking change in cache keys (which would invalidate existing caches), we keep the normal URI
251+
# for GET requests as key, but use a prefix for HEAD.
252+
set $docker_proxy_cache_prefix "";
253+
if ($request_method = HEAD) {
254+
set $docker_proxy_cache_prefix "HEAD:";
255+
}
256+
247257
# Hide/ignore headers from caching. S3 especially likes to send Expires headers in the past in some situations.
248258
proxy_hide_header Set-Cookie;
249259
proxy_ignore_headers X-Accel-Expires Expires Cache-Control Set-Cookie;
@@ -307,7 +317,7 @@ echo "Docker configured with HTTPS_PROXY=$scheme://$http_host/"
307317
proxy_cache cache;
308318
# But we store the result with the cache key of the original request URI
309319
# so that future clients don't need to follow the redirect too
310-
proxy_cache_key $original_uri;
320+
proxy_cache_key $docker_proxy_cache_prefix$original_uri;
311321
}
312322

313323
# by default, dont cache anything.

Diff for: nginx.manifest.common.conf

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
add_header X-Docker-Registry-Proxy-Cache-Type "$docker_proxy_request_type";
44
proxy_pass https://$targetHost;
55
proxy_cache cache;
6-
proxy_cache_key $uri;
6+
proxy_cache_key $docker_proxy_cache_prefix$uri;
77
proxy_intercept_errors on;
88
error_page 301 302 307 = @handle_redirects;

0 commit comments

Comments
 (0)