Last active
March 9, 2024 07:10
-
-
Save kerus1024/69f2b3c45fe3049b07095c658031ba42 to your computer and use it in GitHub Desktop.
Harbor Docker registry Cache via nginx proxy cache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
client_max_body_size 0; | |
location ~ "^/v2/.*/manifests/[a-zA-Z0-9\_][a-zA-Z0-9\-\_\.]{0,127}$" { | |
proxy_set_header Host $host; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forwarded-Proto $scheme; | |
proxy_http_version 1.1; | |
proxy_set_header Connection ""; | |
proxy_cache proxycache; | |
proxy_cache_methods GET HEAD; | |
proxy_cache_convert_head off; | |
proxy_ignore_headers Vary Cache-Control Set-Cookie; | |
proxy_cache_valid 200 307 1m; | |
proxy_cache_valid 404 5s; | |
proxy_cache_lock on; | |
proxy_cache_lock_age 20s; | |
proxy_cache_lock_timeout 20s; | |
proxy_cache_key "cr#$request_method#$request_uri"; | |
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504; | |
proxy_cache_revalidate on; | |
proxy_hide_header Vary; | |
proxy_hide_header Vary; | |
proxy_hide_header Cache-Control; | |
proxy_hide_header Set-Cookie; | |
add_header X-Cache-Status $upstream_cache_status; | |
proxy_pass http://127.0.0.1:80; | |
} | |
location ~ "^/v2/.*/blobs/sha256:([a-z0-9]{64})$" { | |
proxy_set_header Host $host; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forwarded-Proto $scheme; | |
proxy_http_version 1.1; | |
proxy_set_header Connection ""; | |
proxy_buffer_size 1024k; | |
proxy_buffers 1024 1024k; | |
proxy_busy_buffers_size 1024k; | |
proxy_set_header Accept-Encoding gzip; | |
proxy_cache proxycache; | |
proxy_cache_methods GET HEAD; | |
proxy_cache_convert_head off; | |
proxy_ignore_headers Vary Cache-Control Set-Cookie; | |
proxy_cache_valid 200 307 15d; | |
proxy_cache_valid 301 1m; | |
proxy_cache_lock on; | |
proxy_cache_lock_age 20s; | |
proxy_cache_lock_timeout 20s; | |
proxy_cache_key "cr#$request_method##object:$1"; | |
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504; | |
proxy_cache_revalidate on; | |
proxy_redirect off; | |
proxy_hide_header Vary; | |
proxy_hide_header Cache-Control; | |
proxy_hide_header Set-Cookie; | |
gzip_types application/octet-stream application/json; | |
gzip_static on; | |
gzip_vary on; | |
add_header X-Cache-Status "$upstream_cache_status"; | |
client_body_buffer_size 1024K; | |
client_body_in_file_only clean; | |
proxy_pass http://127.0.0.1:80; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Authorization has not been considered, please be careful when using confidential containers.