1

I’m having some issues using Traefik in a Swarm. With the following configuration I’m expecting traffic on port 80 to reach the traefik service and then be dispatched it a dedicated port on the proxy service but it seems the traffic does not go through.

traefik: image: traefik:1.3.5 command: --web --docker --docker.swarmmode --docker.watch --docker.domain=app.dev --logLevel=DEBUG ports: - "80:80" - "8080:8080" volumes: - /var/run/docker.sock:/var/run/docker.sock - /dev/null:/traefik.toml deploy: replicas: 1 placement: constraints: [node.role == manager] restart_policy: condition: on-failure

proxy: image: 'myapp/proxy' deploy: replicas: 1 labels: - "traefik.backend=proxy" - "traefik.web.frontend.rule=Host:www.app.dev" - "traefik.web.port=8000" - "traefik.wss.frontend.rule=Host:wss.app.dev" - "traefik.wss.protocol=ws" - "traefik.wss.port=9002" - "traefik.api.frontend.rule=Host:api.app.dev" - "traefik.api.port=8002" - "traefik.lnr.frontend.rule=Host:lnr.app.dev" - "traefik.lnr.port=9001" restart_policy: condition: on-failure

I have the following entry in the logs:

app_traefik.1.84giy7wqf3n6@moby    | time="2017-08-08T11:27:34Z" level=debug msg="Filtering container without port and no traefik.port label app_proxy.1"

I get a 404 when I send a request to the app:

curl -H "Host:www.app.dev" http://localhost
404 page not found

Is the multi ports for a single backend taken into account in the context of a Swarm as it is when run with Docker Compose ?

Any idea what I’m missing here ?

Luc
  • 16,604
  • 34
  • 121
  • 183

2 Answers2

1

I had also the same problem. I am using docker compose for running the containers and there are two open ports inside my service and I want to access to every ports with the different domain. I solve it like below

    labels:
  - "traefik.enable=true"
  - "traefik.http.routers.s1.rule=Host(`sub1.sample.com`)"
  - "traefik.http.routers.s1.entrypoints=websecure"
  - "traefik.http.routers.s1.service=s1"
  - "traefik.http.routers.s1.tls.certresolver=myhttps"
  - "traefik.http.services.s1.loadbalancer.server.port=8543"
  - "traefik.http.services.s1.loadbalancer.server.scheme=https"

  - "traefik.http.routers.s1.rule=Host(`sub2.sample.com`)"
  - "traefik.http.routers.s2.entrypoints=websecure"
  - "traefik.http.routers.s2.service=s2"
  - "traefik.http.routers.s2.tls.certresolver=myhttps"
  - "traefik.http.services.s2.loadbalancer.server.port=9543"
  - "traefik.http.services.s2.loadbalancer.server.scheme=https"
  - "traefik.docker.network=traefik_default"

I have also using letsencrypt for handling https

moreover I add this line for making secure connection between traefik and my container

      - "traefik.http.services.s2.loadbalancer.server.scheme=https"

if you do not need https you can omit this lines

      - "traefik.http.routers.s1.tls.certresolver=myhttps"

and change the websecure to web in this line

      - "traefik.http.routers.s1.entrypoints=web"
Mehdi Alisoltani
  • 349
  • 3
  • 13
0

Figured out it requires to add traefik.port and traefik.frontend.rule even if they are not used. https://github.com/containous/traefik/issues/1840

Luc
  • 16,604
  • 34
  • 121
  • 183