Skip to content
Merged
Changes from 1 commit
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: 8 additions & 4 deletions nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,9 @@ 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;

# 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 All @@ -275,15 +278,15 @@ 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";
set $cache_key $2;
set $cache_key $request_method$2;
include "/etc/nginx/nginx.manifest.common.conf";
}

# 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";
set $cache_key $uri;
set $cache_key $request_method$uri;
include "/etc/nginx/nginx.manifest.common.conf";
}

Expand All @@ -296,7 +299,7 @@ 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
location ~ ^/v2/(.*)/blobs/ {
set $docker_proxy_request_type "blob-mutable";
set $cache_key $uri;
set $cache_key $request_method$uri;
proxy_cache_valid 0s;
include "/etc/nginx/nginx.manifest.stale.conf";
}
Expand All @@ -307,6 +310,7 @@ echo "Docker configured with HTTPS_PROXY=$scheme://$http_host/"
# the proxy_* directives, these will disappear
set $original_uri $uri;
set $orig_loc $upstream_http_location;
set $orig_cache_key $cache_key
# Handle relative re-direct in Location header (as opposed to absolute)
if ($upstream_http_location !~ "^http") {
set $orig_loc "${scheme}://${host}${upstream_http_location}";
Expand All @@ -322,7 +326,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$slice_range;
proxy_cache_key $orig_cache_key$slice_range;
}

# by default, dont cache anything.
Expand Down