Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Traefik v2 [how to route to specific port]

I'm trying to start the change of backends to be compatible with traefik v2.0.

The old configuration was:

  labels:
    - traefik.port=8500
    - traefik.docker.network=proxy
    - traefik.frontend.rule=Host:consul.{DOMAIN}

I assumed, the network is not necessary anymore, it would change the new traefik for:

    - traefik.http.routers.consul-server-bootstrap.rule=Host('consul.scoob.thrust.com.br')

But how I set, that this should forward to my backend at port 8500? and not 80 where the entrypoint was reached at Traefik?

My goal would try to accomplish something like this: https://docs.traefik.io/user-guide/cluster-docker-consul/#migrate-configuration-to-consul

Is it still possible? I saw, there was no --consul or storeconfig command in v2.0

like image 626
Gabriel Bastos Avatar asked Apr 11 '19 22:04

Gabriel Bastos


Video Answer


1 Answers

You need traefik.http.services.{SERVICE}.loadbalancer.server.port

  labels:
    - "traefik.http.services.{SERVICE}.loadbalancer.server.port=8500"
    - "traefik.docker.network=proxy"
    - "traefik.http.routers.{SERVICE}.rule=Host(`{DOMAIN}`)"
  • Replace {SERVICE} with the name of your service.
  • Replace {DOMAIN} with your domain name.

If you want to remove the proxy network you'll need to look at https://docs.traefik.io/v2.0/providers/docker/#usebindportip

like image 194
hdorio Avatar answered Sep 20 '22 05:09

hdorio