# Config from labels on swarm

**URL:** <https://community.traefik.io/t/config-from-labels-on-swarm/2222>\
**Category:** Traefik v2\
**Tags:** docker, docker-swarm\
**Created:** [October 8, 2019, 11:31am UTC](https://community.traefik.io/t/config-from-labels-on-swarm/2222 "2019-10-08T11:31:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![clausdenk](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/clausdenk/32/2239_2.png) [@clausdenk](https://community.traefik.io/u/clausdenk)\
**Post date:** [October 8, 2019, 11:31am UTC](https://community.traefik.io/t/config-from-labels-on-swarm/2222/1 "2019-10-08T11:31:52Z")

</div>

Hi,

I am trying to implement [http to https redirection](https://community.containo.us/t/global-http-to-https-redirect-in-v2/1658/3) with v2 on a swarm. I have been succesfull with a file provider, i.e. with

```auto
[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

```auto
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

---

<div class="post-metadata">

**Author:** ![ldez](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/ldez/32/5_2.png) [@ldez](https://community.traefik.io/u/ldez)\
**Post date:** [October 8, 2019, 6:54pm UTC](https://community.traefik.io/t/config-from-labels-on-swarm/2222/2 "2019-10-08T18:54:50Z")

</div>

Hello,

> [@clausdenk](#):
>
> - "traefik.http.services.noop.loadBalancer.servers.url=192.168.1.1"

replace the previous label by:

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

```

> **[Traefik Docker Routing Documentation - Traefik](https://doc.traefik.io/traefik/v2.0/routing/providers/docker/)**
>
> This guide will teach you how to attach labels to your containers, to route traffic and load balance with Traefik and Docker.

---

<div class="post-metadata">

**Author:** ![clausdenk](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/clausdenk/32/2239_2.png) [@clausdenk](https://community.traefik.io/u/clausdenk)\
**Post date:** [October 9, 2019, 7:59am UTC](https://community.traefik.io/t/config-from-labels-on-swarm/2222/3 "2019-10-09T07:59:44Z")

</div>

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:

```auto
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!
