Skip to content

Instantly share code, notes, and snippets.

@jrussellsmyth
Last active November 10, 2024 06:00
Show Gist options
  • Select an option

  • Save jrussellsmyth/244b2a5f3e33a333a23ddbf1243833d0 to your computer and use it in GitHub Desktop.

Select an option

Save jrussellsmyth/244b2a5f3e33a333a23ddbf1243833d0 to your computer and use it in GitHub Desktop.
Docker lables for traefik
services:
myservice:
depends_on:
- traefik
labels:
- "traefik.enable=true"
- "traefik.http.routers.myservice.rule=Host(`localdev.jrussellsmyth.com`) && PathPrefix(`/myservice`)"
- "traefik.http.routers.myservice.service=myservice"
- "traefik.http.routers.myservice.entrypoints=web"
- "traefik.http.services.myservice.loadbalancer.server.port=80"
- "traefik.http.services.myservice.loadbalancer.healthcheck.path=/actuator/health"
- "traefik.http.services.myservice.loadbalancer.healthcheck.interval=10s"
- "traefik.http.services.myservice.loadbalancer.healthcheck.timeout=3s"
- "traefik.http.middlewares.strip-myservice-prefix.stripprefix.prefixes=/myservice"
- "traefik.http.routers.myservice.middlewares=strip-myservice-prefix"
# second router does not strip the prefix.. perhaps you have some reason to need the full path, like spring autogenerated thiings
- "traefik.http.routers.myservice_full.rule=Host(`localstack.nextiva.xyz`) && (PathPrefix(`/myservice/oauth2`)||PathPrefix(`/myservice/login/oauth2/`)||PathPrefix(`/myservice/saml2/sso`))"
- "traefik.http.routers.myservice_full.service=myservice"
- "traefik.http.routers.myservice_fullh.entrypoints=web"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment