Very basic question

I am trying to learn traefik and have created this yaml file:

entryPoints:
  web:
    address: ":80"

http:
  routers:
    bc-router:
      entryPoints: "web"
      rule: "Path(`/bc`)"
      service: "bc-service"
  services:
    bc-service:
      loadBalancer:
        sticky:
          cookie: {}
        servers:
        - url: "http://172.19.85.38/"
        - url: "http://172.19.94.56/"

api:
  insecure: true
  dashboard: true

But I seem to be missing something, my traefik only picks up the api/dashboard setting:

(I have tried to set dashboard: false to see that if reads this config file).

What obvious piece am I missing to do a simple load balancing between two urls?

Thanks

I found out that the rule needs to have Host defined as well. Part alone doesn't work.
Now I can see the service, but I get a 404 when trying to access it:

image

That is not correct. A Path rule will work adequately.

Your issue is mixing static and dynamic configuration in the same file.

Got it, thanks. So now I split this in traefik.yaml:

entryPoints:
  web:
    address: ":80"

api:
  insecure: true
  dashboard: true

providers:
  file:
    filename: c:/etc/traefik/bc-service.yaml
    watch: true

and bc-service.yaml:

http:
  routers:
    bc-router:
      entryPoints:
      - web
      rule: Host(`*`)
      service: bc-service

  services:
    bc-service:
      loadBalancer:
        sticky:
          cookie: {}
        servers:
        - url: http://172.19.85.38
        - url: http://172.19.94.56

My expectation is now, that when navigating to http://ip-of-traefik/bc would return data from http://172.19.85.38/bc or http://172.19.94.56/bc on a round robin - but I still get a 404.

Got it to work.

http:
  routers:
    bc-router:
      entryPoints:
      - web
      rule: PathPrefix(`/BC`)
      service: bc-service
  services:
    bc-service:
      loadBalancer:
        sticky:
          cookie: {}
        servers:
        - url: http://172.19.84.103/
        - url: http://172.19.85.205/

Thanks

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.