Skip to content

Instantly share code, notes, and snippets.

@liejuntao001
Created September 19, 2021 03:56
Show Gist options
  • Save liejuntao001/0ec32b32d111a5c266564a256872aada to your computer and use it in GitHub Desktop.
Save liejuntao001/0ec32b32d111a5c266564a256872aada to your computer and use it in GitHub Desktop.
Traefik 2.x rules for Artifactory 7.x
version: '3'
services:
artifactory:
## others ommited
networks:
- proxy
- artifactory
labels:
- "traefik.enable=true"
- "traefik.docker.network=proxy"
# artifactory 8082 port
- "traefik.http.services.artifactory.loadbalancer.server.port=8082"
# artifactory 8081 port
- "traefik.http.services.artifactoryApi.loadbalancer.server.port=8081"
# artifactory UI route
- "traefik.http.routers.artifactory.service=artifactory"
- "traefik.http.routers.artifactory.tls=true"
- "traefik.http.routers.artifactory.tls.certresolver=default"
- "traefik.http.routers.artifactory.rule=$ARTIFACTORY_RULE"
# artifactory api route
- "traefik.http.routers.artifactoryApi.service=artifactoryApi"
- "traefik.http.routers.artifactoryApi.tls=true"
- "traefik.http.routers.artifactoryApi.tls.certresolver=default"
- "traefik.http.routers.artifactoryApi.rule=$ARTIFACTORYAPI_RULE"
# artifactory docker route
- "traefik.http.routers.artifactoryDocker.service=artifactoryApi"
- "traefik.http.routers.artifactoryDocker.tls=true"
- "traefik.http.routers.artifactoryDocker.tls.certresolver=default"
- "traefik.http.routers.artifactoryDocker.rule=$ARTIFACTORYDOCKER_RULE"
# rewrite for /ui/
- "traefik.http.middlewares.artifact_uiRedirect.replacepathregex.regex=^/$$"
- "traefik.http.middlewares.artifact_uiRedirect.replacepathregex.replacement=/ui/"
- "traefik.http.middlewares.artifact_uiLongRedirect.replacepathregex.regex=^/ui(/)?$$"
- "traefik.http.middlewares.artifact_uiLongRedirect.replacepathregex.replacement=/ui/"
# rewrite for docker api
- "traefik.http.middlewares.artifact_dockerRedirect.replacepathregex.regex=https://(.*)\\.myjfrog\\.com/(v1|v2)/(.*)"
- "traefik.http.middlewares.artifact_dockerRedirect.replacepathregex.replacement=https://$$1.myjfrog.com/artifactory/api/docker/$$1/$$2/$$3"
# apply the middlewares
- "traefik.http.routers.artifactory.middlewares=default-securityHeader@file,artifact_uiRedirect,artifact_uiLongRedirect"
- "traefik.http.routers.artifactoryApi.middlewares=default-securityHeader@file"
- "traefik.http.routers.artifactoryDocker.middlewares=default-securityHeader@file,artifact_dockerRedirect"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment