# How to redirect to https with label in docker-compose file?

**URL:** <https://community.traefik.io/t/how-to-redirect-to-https-with-label-in-docker-compose-file/7475>\
**Category:** Traefik v1\
**Tags:** docker\
**Created:** [August 29, 2020, 11:13pm UTC](https://community.traefik.io/t/how-to-redirect-to-https-with-label-in-docker-compose-file/7475 "2020-08-29T23:13:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jocke](https://avatars.discourse-cdn.com/v4/letter/j/dec6dc/32.png) [@Jocke](https://community.traefik.io/u/Jocke)\
**Post date:** [August 29, 2020, 11:13pm UTC](https://community.traefik.io/t/how-to-redirect-to-https-with-label-in-docker-compose-file/7475/1 "2020-08-29T23:13:58Z")

</div>

Using version: traefik:1.7.3-alpine

How can I redirect to https with label for one specific service only in docker-compose file?

(I find it very confusing where to find the complete reference documentation for docker concerning what labels to use. I have looked at [https://docs.traefik.io/v1.7/configuration/backends/docker/](https://docs.traefik.io/v1.7/configuration/backends/docker/) (not sure if that is the right doc..?) and tried different labels related to https without succeeding. And in the same page there is only "Backend" documentation - where is the Frontend one for instance? It seems very incomplete). I have tried (it is not clear to me in the documentation which one, if any of them, to use)

```auto
traefik.protocol: https # Gives "Bad Gateway"
traefik.frontend.redirect.entryPoint: https # Gives "404 Page not found"

```

---

<div class="post-metadata">

**Author:** ![Jocke](https://avatars.discourse-cdn.com/v4/letter/j/dec6dc/32.png) [@Jocke](https://community.traefik.io/u/Jocke)\
**Post date:** [August 30, 2020, 7:37am UTC](https://community.traefik.io/t/how-to-redirect-to-https-with-label-in-docker-compose-file/7475/2 "2020-08-30T07:37:50Z")

</div>

I have now also tried [https://docs.traefik.io/middlewares/redirectscheme/](https://docs.traefik.io/middlewares/redirectscheme/). It seems like the port redirection takes effect, but not the protocol one :

```auto
traefik.http.middlewares.mytest.redirectscheme.scheme: https
traefik.http.middlewares.mytest.redirectscheme.port: 8443

```

No difference if I add the permanent: true line as well (whatever "permanent" mean in this case...).

```auto
traefik.http.middlewares.mytest.redirectscheme.scheme: https
traefik.http.middlewares.mytest.redirectscheme.permanent: true
traefik.http.middlewares.mytest.redirectscheme.port: 8443

```

Neither if I quote "https" it works...

EDIT: After adding a lot of different labels it now at least looks to me like it is right - but still I get "404 page not found". Here is the docker compose file labels:

```auto
labels:
  traefik.frontend.rule: "Host:mytest.${PROJECT_NAME}.${DOCKER_HOSTNAME}"
  traefik.frontend.passHostHeader: "true"
  traefik.frontend.entryPoints: http,https
  traefik.frontend.redirect.entryPoint: "https"
  traefik.port: "8080"
  traefik.http.middlewares.main.redirectscheme.protocol: https
  traefik.http.middlewares.main.redirectscheme.port: 8443

```

The traefik dashboard shows that the backend server is

```auto
https://192.168.208.11:8443

```

which is what I would expect. Even though the link URL I then click is

```auto
http://mytest.myproject.locahost/mytestpage

```

I do get "404 page not found"  
If I try to access

```auto
https://192.168.208.11:8443/mytestpage

```

directly I do come to my page. What on earth is missing now?  
(NOTE: I have a link [http://myproject.localhost/](http://myproject.localhost/) that is working fine (it does not include any redirection though), so I have got something right with Traefik at least. Here is my traefik docker service:

```auto
  traefik:
    restart: always
    image: traefik:1.7.3-alpine
    command: --debug --api --docker --docker.network=proxy
    labels:
      traefik.port: "8080"
      traefik.frontend.rule: "Host:traefik.${DOCKER_HOSTNAME}"
    ports:
      - "${TRAEFIK_HTTP}:80"
    networks:
      - proxy
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ./traefik.toml:/etc/traefik/traefik.toml

```

TRAEFIK\_HTTP=80  
DOCKER\_HOSTNAME=localhost  
PROJECT\_NAME=myproject  
)

---

<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:** [August 30, 2020, 9:43pm UTC](https://community.traefik.io/t/how-to-redirect-to-https-with-label-in-docker-compose-file/7475/3 "2020-08-30T21:43:41Z")

</div>

Hello,

you mixed Traefik v1 and Traefik v2 configuration.

Take a look to this following documentation:

[https://docs.traefik.io/v1.7/configuration/backends/docker/](https://docs.traefik.io/v1.7/configuration/backends/docker/)

```auto
traefik.frontend.redirect.entryPoint=https

```

---

<div class="post-metadata">

**Author:** ![Jocke](https://avatars.discourse-cdn.com/v4/letter/j/dec6dc/32.png) [@Jocke](https://community.traefik.io/u/Jocke)\
**Post date:** [August 31, 2020, 5:09am UTC](https://community.traefik.io/t/how-to-redirect-to-https-with-label-in-docker-compose-file/7475/4 "2020-08-31T05:09:35Z")

</div>

Well, as you can see I already have that line.  
If I remove v2 lines, and it looks like this

```auto
labels:
  traefik.frontend.rule: "Host:main.${PROJECT_NAME}.${DOCKER_HOSTNAME}"
  traefik.frontend.passHostHeader: "true"
  traefik.frontend.entryPoints: http,https
  traefik.frontend.redirect.entryPoint: "https"
  traefik.port: "8080"

```

it still fails, _and_ the Traefik dashboard will show the backend as

```auto
http://mytest.myproject.localhost:8080

```

which is **not** as expected (it does not look as I would expect it anyway since it is the wrong scheme and wrong port).

The documentation at [https://docs.traefik.io/middlewares/redirectscheme/](https://docs.traefik.io/middlewares/redirectscheme/) does not mention **anything** about any version support.
