Skip to content

Disable conversion of HEAD method to GET #89

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,16 @@ echo "Docker configured with HTTPS_PROXY=$scheme://$http_host/"
proxy_ignore_client_abort 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.
proxy_hide_header Set-Cookie;
proxy_ignore_headers X-Accel-Expires Expires Cache-Control Set-Cookie;
Expand Down Expand Up @@ -307,7 +317,7 @@ echo "Docker configured with HTTPS_PROXY=$scheme://$http_host/"
proxy_cache cache;
# 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
proxy_cache_key $original_uri;
proxy_cache_key $docker_proxy_cache_prefix$original_uri;
}

# by default, dont cache anything.
Expand Down
2 changes: 1 addition & 1 deletion nginx.manifest.common.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
add_header X-Docker-Registry-Proxy-Cache-Type "$docker_proxy_request_type";
proxy_pass https://$targetHost;
proxy_cache cache;
proxy_cache_key $uri;
proxy_cache_key $docker_proxy_cache_prefix$uri;
proxy_intercept_errors on;
error_page 301 302 307 = @handle_redirects;