Config from labels on swarm

Hi,

I am trying to implement http to https redirection with v2 on a swarm. I have been succesfull with a file provider, i.e. with

[http.routers]
  [http.routers.web_router]
    entryPoints = ["web"]
    middlewares = ["https-redirect"]
    rule = "HostRegexp(`{host:.+}`)"
    service = "noop"

[http.services]
  [http.services.noop.loadBalancer]
    [[http.services.noop.loadBalancer.servers]]
      url = "http://192.168.0.1"

[http.middlewares]
  [http.middlewares.https-redirect.redirectScheme]
    scheme = "https"

However, I can't seem to get Traefik read the docker labels on the swarm as provided in the yml file

version: "3.3"

services:

  traefik:
    image: "traefik:v2.0.0"
    command:
      - --entrypoints.web.address=:80
      - --entrypoints.websecure.address=:443
      - --providers.docker=true
      - --log.level=DEBUG
    ports:
      - "80:80"
      - "443:443"
    deploy:
      labels:
        - "traefik.http.routers.http-catchall.rule=hostregexp(`{host:.+}`)"
        - "traefik.http.routers.http-catchall.entrypoints=web"
        - "traefik.http.routers.http-catchall.service=noop"
        - "traefik.http.routers.http-catchall.middlewares=redirect-to-https@docker"
        - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
        - "traefik.http.services.noop.loadBalancer.servers.url=192.168.1.1"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"

The router and middleware are not created. I have tried the "labels" section as a subsection of "deploy" and directly below the service.

What am I missing here?

Kind regards, Claus

Hello,

replace the previous label by:

- "traefik.http.services.noop.loadBalancer.server.port=80"

Hi ldez,

thanks a lot! I was also missing the 'swarmMode' setting and the server port (which has to be defined apparently). With the following config it finally works:

version: "3.3"
services:
  traefik:
    image: "traefik:v2.0.0"
    command:
      - --entrypoints.web.address=:80
      - --entrypoints.websecure.address=:443
      - --providers.docker=true
      - --providers.docker.swarmMode=true
      - --log.level=DEBUG
    ports:
      - "80:80"
      - "443:443"
    deploy:
      labels:
        - "traefik.http.routers.redirecttohttps.rule=hostregexp(`{host:.+}`)"
        - "traefik.http.routers.redirecttohttps.entrypoints=web"
        - "traefik.http.routers.redirecttohttps.service=noop"
        - "traefik.http.routers.redirecttohttps.middlewares=httpsredirect"
        - "traefik.http.middlewares.httpsredirect.redirectscheme.scheme=https"
        - "traefik.http.services.noop.loadbalancer.server.port=80"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"

Great!