Dragonfly icon indicating copy to clipboard operation
Dragonfly copied to clipboard

Rewrite urls in dfdaemon

Open jordanrinke opened this issue 4 years ago • 2 comments

Why you need it?

We have multiple transparent docker proxy caches internal to our network, but they are potentially different based on the site, provider etc. It would be useful if we could add a regex rewrite rule to transparently point to our local caches for draongfly, it would reduce our WAN traffic, and maximize our LCR choices while maintaining standard image paths/names in the manifests applied across all clusters. We use squid+https://github.com/rchunping/squid-urlrewrite to do this now, sitting in front of the supernode. If dfdaemon did the rewriting, we could eliminate squid/rewriting entirely and leverage just dragonfly.

How it could be?

Additional config in yaml to specify a url match pattern, and replace pattern. The format used in squid-urlrewrite works well for us currently.

Other related information

jordanrinke avatar Jun 14 '20 13:06 jordanrinke

Currently we only have very simple matching and modification rules in dfdaemon, which can modify the protocol (http or https) and host. Will this meet your need?

proxies: 
# redirect all image layer requests to host registry-cache
- regx: blobs/sha256.*
  # hostname to redirect to
  redirect: registry-cache

Sorry that the redirect field seems to be missing from the docs for now. We'll fix that soon.

inoc603 avatar Jun 15 '20 05:06 inoc603

This may work, I will read the code and test with it. Thanks.

jordanrinke avatar Jun 15 '20 15:06 jordanrinke