Changed to cache all traffic throught proxy.
This commit is contained in:
34
nginx.conf
34
nginx.conf
@@ -236,13 +236,14 @@ echo "Docker configured with HTTPS_PROXY=$scheme://$http_host/"
|
||||
proxy_cache_lock on;
|
||||
proxy_cache_lock_timeout 880s;
|
||||
|
||||
# Cache all 200, 206 for 60 days.
|
||||
proxy_cache_valid 200 206 60d;
|
||||
# Cache all 200, 206 for 720d days.
|
||||
proxy_cache_valid 200 206 720d;
|
||||
|
||||
# Some extra settings to maximize cache hits and efficiency
|
||||
proxy_force_ranges on;
|
||||
proxy_ignore_client_abort on;
|
||||
proxy_cache_revalidate on;
|
||||
|
||||
include "/etc/nginx/nginx.cache.revalidate.conf";
|
||||
|
||||
# Hide/ignore headers from caching. S3 especially likes to send Expires headers in the past in some situations.
|
||||
proxy_hide_header Set-Cookie;
|
||||
@@ -264,31 +265,16 @@ 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";
|
||||
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";
|
||||
location / {
|
||||
set $docker_proxy_request_type "proxy";
|
||||
include "/etc/nginx/nginx.manifest.common.conf";
|
||||
proxy_cache_use_stale error timeout http_500 http_502 http_504 http_429;
|
||||
}
|
||||
|
||||
# Config for manifest URL caching is generated by the entrypoint based on ENVs.
|
||||
# Go check it out, entrypoint.sh
|
||||
include "/etc/nginx/nginx.manifest.caching.config.conf";
|
||||
|
||||
|
||||
# Cache blobs requests that are not by digest
|
||||
# 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";
|
||||
proxy_cache_valid 0s;
|
||||
include "/etc/nginx/nginx.manifest.stale.conf";
|
||||
}
|
||||
|
||||
location @handle_redirects {
|
||||
#store the current state of the world so we can reuse it in a minute
|
||||
# We need to capture these values now, because as soon as we invoke
|
||||
@@ -309,11 +295,5 @@ echo "Docker configured with HTTPS_PROXY=$scheme://$http_host/"
|
||||
# so that future clients don't need to follow the redirect too
|
||||
proxy_cache_key $original_uri;
|
||||
}
|
||||
|
||||
# by default, dont cache anything.
|
||||
location / {
|
||||
proxy_pass https://$targetHost;
|
||||
proxy_cache off;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user