when HTTP_REQUEST {
if { [string tolower [HTTP::uri]] starts_with "/v2/" } {
# Set Artifactory server information
set ARTI_PORT "443"
set ARTI_PROTO "https"
set TIMEOUT 900
# Parse original host request
scan [HTTP::host] %\[^.\].%\[^.\].%s REPO DOMAIN TLD
# Rewrite the uri
HTTP::uri /artifactory/api/docker/$REPO[HTTP::uri]
# Set request headers
HTTP::header insert X-Artifactory-Override-Base-Url "$ARTI_PROTO://[HTTP::host]/artifactory"
HTTP::header insert X-Forwarded-Port "$ARTI_PORT"
HTTP::header insert X-Forwarded-Proto "$ARTI_PROTO"
HTTP::header insert Host "[HTTP::host]"
# Update the idle timeout
IP::idle_timeout $TIMEOUT
}
} Basically, take a docker command such as docker pull docker.artifactory.test/busybox, where docker is the repo, busybox is the docker image, and artifactory.test is the server name.
You want it to rewrite the uri to /artifactory/api/docker/<repo>/<image>, or /artifactory/api/docker/docker/busybox
Take a look at the following for more info:
https://devcentral.f5.com/articles/irules-101-16-parsing-strings-with-the-tcl-scan-command