Disable conversion of HEAD method to GET

pull/89/head
Aaron Spettl 2021-04-23 19:44:52 +02:00
parent 2f55921a0d
commit 399ccfc351
2 changed files with 12 additions and 2 deletions

View File

@ -240,6 +240,16 @@ echo "Docker configured with HTTPS_PROXY=$scheme://$http_host/"
proxy_ignore_client_abort on; proxy_ignore_client_abort on;
proxy_cache_revalidate on; proxy_cache_revalidate on;
# Avoid conversion of HEAD method to GET
proxy_cache_convert_head off;
# HEAD requests are to be cached separately from GET, so they need a different cache key.
# To avoid a breaking change in cache keys (which would invalidate existing caches), we keep the normal URI
# for GET requests as key, but use a prefix for HEAD.
set $docker_proxy_cache_prefix "";
if ($request_method = HEAD) {
set $docker_proxy_cache_prefix "HEAD:";
}
# Hide/ignore headers from caching. S3 especially likes to send Expires headers in the past in some situations. # Hide/ignore headers from caching. S3 especially likes to send Expires headers in the past in some situations.
proxy_hide_header Set-Cookie; proxy_hide_header Set-Cookie;
proxy_ignore_headers X-Accel-Expires Expires Cache-Control Set-Cookie; proxy_ignore_headers X-Accel-Expires Expires Cache-Control Set-Cookie;
@ -303,7 +313,7 @@ echo "Docker configured with HTTPS_PROXY=$scheme://$http_host/"
proxy_cache cache; proxy_cache cache;
# But we store the result with the cache key of the original request URI # But we store the result with the cache key of the original request URI
# so that future clients don't need to follow the redirect too # so that future clients don't need to follow the redirect too
proxy_cache_key $original_uri; proxy_cache_key $docker_proxy_cache_prefix$original_uri;
} }
# by default, dont cache anything. # by default, dont cache anything.

View File

@ -3,6 +3,6 @@
add_header X-Docker-Registry-Proxy-Cache-Type "$docker_proxy_request_type"; add_header X-Docker-Registry-Proxy-Cache-Type "$docker_proxy_request_type";
proxy_pass https://$targetHost; proxy_pass https://$targetHost;
proxy_cache cache; proxy_cache cache;
proxy_cache_key $uri; proxy_cache_key $docker_proxy_cache_prefix$uri;
proxy_intercept_errors on; proxy_intercept_errors on;
error_page 301 302 307 = @handle_redirects; error_page 301 302 307 = @handle_redirects;