# Edit this domain to yours
DOMAIN="example.com"
cat << EOF > /etc/caddy/Caddyfile
hub.docker.${DOMAIN} {
encode gzip
reverse_proxy * https://registry-1.docker.io {
header_up Host registry-1.docker.io
header_up X-Real-IP {http.request.remote.host}
header_up X-Forwarded-For {http.request.remote.host}
header_up X-Forwarded-Port {http.request.port}
header_up X-Forwarded-Proto {http.request.scheme}
header_down Set-Cookie registry-1.docker.io docker.${DOMAIN}
header_down Www-Authenticate "Bearer realm=\"https://auth.docker.${DOMAIN}/token\",service=\"registry.docker.io\""
header_down Location "https://production.cloudflare.docker.com" "https://production.cloudflare.docker.${DOMAIN}"
}
}
auth.docker.${DOMAIN} {
encode gzip
reverse_proxy * https://auth.docker.io {
header_up Host auth.docker.io
header_up X-Real-IP {http.request.remote.host}
header_up X-Forwarded-For {http.request.remote.host}
header_up X-Forwarded-Port {http.request.port}
header_up X-Forwarded-Proto {http.request.scheme}
header_down Set-Cookie auth.docker.io docker.${DOMAIN}
}
}
production.cloudflare.docker.${DOMAIN} {
encode gzip
reverse_proxy * https://production.cloudflare.docker.com {
header_up Host production.cloudflare.docker.com
header_up X-Real-IP {http.request.remote.host}
header_up X-Forwarded-For {http.request.remote.host}
header_up X-Forwarded-Port {http.request.port}
header_up X-Forwarded-Proto {http.request.scheme}
header_down Set-Cookie production.cloudflare.docker.com docker.${DOMAIN}
}
}
hub.quay.${DOMAIN} {
encode gzip
reverse_proxy * https://quay.io {
header_up Host quay.io
header_up X-Real-IP {http.request.remote.host}
header_up X-Forwarded-For {http.request.remote.host}
header_up X-Forwarded-Port {http.request.port}
header_up X-Forwarded-Proto {http.request.scheme}
header_down Set-Cookie quay.io quay.${DOMAIN}
header_down Www-Authenticate "Bearer realm=\"https://hub.quay.${DOMAIN}/v2/auth\",service=\"quay.io\""
}
}
hub.gcr.${DOMAIN} {
encode gzip
reverse_proxy * https://gcr.io {
header_up Host gcr.io
header_up X-Real-IP {http.request.remote.host}
header_up X-Forwarded-For {http.request.remote.host}
header_up X-Forwarded-Port {http.request.port}
header_up X-Forwarded-Proto {http.request.scheme}
header_down Set-Cookie k8s.gcr.io gcr.${DOMAIN}
header_down Www-Authenticate "Bearer realm=\"https://hub.gcr.${DOMAIN}/v2/token\",service=\"gcr.io\""
}
}
hub.k8s.${DOMAIN} {
encode gzip
reverse_proxy * https://k8s.gcr.io {
header_up Host k8s.gcr.io
header_up X-Real-IP {http.request.remote.host}
header_up X-Forwarded-For {http.request.remote.host}
header_up X-Forwarded-Port {http.request.port}
header_up X-Forwarded-Proto {http.request.scheme}
header_down Set-Cookie k8s.gcr.io gcr.${DOMAIN}
header_down Www-Authenticate "Bearer realm=\"https://hub.k8s.${DOMAIN}/v2/token\",service=\"k8s.gcr.io\""
header_down Location "https://storage.googleapis.com" "https://storage.googleapis.${DOMAIN}"
}
}
storage.googleapis.${DOMAIN} {
encode gzip
reverse_proxy * https://storage.googleapis.com {
header_up Host storage.googleapis.com
header_up X-Real-IP {http.request.remote.host}
header_up X-Forwarded-For {http.request.remote.host}
header_up X-Forwarded-Port {http.request.port}
header_up X-Forwarded-Proto {http.request.scheme}
header_down Set-Cookie storage.googleapis.com storage.googleapis.${DOMAIN}
}
}
EOF
systemctl restart caddy
本文标题:用Caddy搭建Docker加速服务
本文连接:https://blog.dextercai.com/archives/226.html
除另行说明,本站文字内容采用创作共用版权 CC-BY-NC-ND 4.0 许可协议,版权归本人所有。
除另行说明,本站图片内容版权归本人所有,任何形式的使用需提前联系。