# General way to get https

**URL:** <https://community.traefik.io/t/general-way-to-get-https/8153>\
**Category:** Traefik v2\
**Tags:** docker-swarm, docker\
**Created:** [October 12, 2020, 11:07am UTC](https://community.traefik.io/t/general-way-to-get-https/8153 "2020-10-12T11:07:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrisbecke](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/chrisbecke/32/2042_2.png) [@chrisbecke](https://community.traefik.io/u/chrisbecke)\
**Post date:** [October 12, 2020, 11:07am UTC](https://community.traefik.io/t/general-way-to-get-https/8153/1 "2020-10-12T11:07:46Z")

</div>

When I first set traefik up it was awesomely simple on docker swarm. Two labels on a service that wanted routing and all was good in the world.

But, and I don't know if Ive not read the docs properly, and/or these problems are solved and I'm just doing something wrong:-

1. I thought there would be some way to turn https on generally so that just the two labels can be used for most configurations. But no, now every service needs to explicitly have configuration settings for two entry-points.

2. I keep on having services in different stacks with identical traefik.http.router/service names interfere with each other. Its super annoying because its shared infrastructure and some team can now roll something out that effects another teams productivity unexpectedly.

3. There seems no way to inhibit the error spam generated from having non traefik enabled services around, even if they are attached to different networks and have no traefik labels at all. exposedByDefault = false must be set, but then an extra label to enable traefik must be added to everything.

Is this as short as I can get the per service dynamic config:

```auto
    deploy:
      labels:
        traefik.enabled: "true"
        traefik.http.routers.cocos_cocos.rule: Host("creator.example.net")
        traefik.http.routers.cocos_cocos.entrypoints: web
        traefik.http.routers.cocos_cocos-tls.rule: Host("creator.example.net")
        traefik.http.routers.cocos_cocos-tls.entrypoints: websecure
        traefik.http.routers.cocos_cocos-tls.tls: "true"
        traefik.http.services.cocos_cocos.loadbalancer.server.port: 80

```

---

<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 12, 2020, 2:31pm UTC](https://community.traefik.io/t/general-way-to-get-https/8153/2 "2020-10-12T14:31:15Z")

</div>

Hello,

You can use [HTTP options](https://doc.traefik.io/traefik/v2.3/routing/entrypoints/#http-options) to simplify your configuration:

```auto
version: '3.7'

services:

  traefik:
    image: traefik:v2.3.1
    ports:
      - 80:80
      - 443:443
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
    command:
      - --log.level=INFO
      - --api

      - --providers.docker.exposedbydefault=false
      
      - --entrypoints.web.address=:80
      - --entrypoints.web.http.redirections.entryPoint.to=websecure
      - --entrypoints.web.http.redirections.entrypoint.scheme=https

      - --entrypoints.websecure.address=:443
      - --entrypoints.websecure.http.tls=true
    labels:
      traefik.enable: 'true'

      # Dashboard
      traefik.http.routers.traefik.rule: Host(`traefik.localhost`)
      traefik.http.routers.traefik.service: api@internal

  # just to have xyz.localhost
  whoami:
    image: containous/whoami:v1.5.0
    labels:
      traefik.enable: 'true'

      traefik.http.routers.whoami.rule: Host(`xyz.localhost`)

```

```auto
version: '3.7'

services:

  traefik:
    image: traefik:v2.3.1
    ports:
      - 80:80
      - 443:443
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
    command:
      - --log.level=INFO
      - --api

      - --providers.docker.exposedbydefault=false
      
      - --entrypoints.web.address=:80

      - --entrypoints.websecure.address=:443
      - --entrypoints.websecure.http.tls=true
    labels:
      traefik.enable: 'true'

      # Dashboard
      traefik.http.routers.traefik.rule: Host(`traefik.localhost`)
      traefik.http.routers.traefik.service: api@internal

  whoami:
    image: containous/whoami:v1.5.0
    labels:
      traefik.enable: 'true'

      traefik.http.routers.whoami.rule: Host(`xyz.localhost`)

```

---

<div class="post-metadata">

**Author:** ![chrisbecke](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/chrisbecke/32/2042_2.png) [@chrisbecke](https://community.traefik.io/u/chrisbecke)\
**Post date:** [October 13, 2020, 11:24am UTC](https://community.traefik.io/t/general-way-to-get-https/8153/3 "2020-10-13T11:24:48Z")

</div>

Oh. This is so much simpler. A one line move of tls=true to static config and suddenly I need to specify Hosts= only once.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/containo/original/2X/b/bd81ebdb578656e76e56ff3cc3eed021d3ba132d.png) [@system](https://community.traefik.io/u/system)\
**Post date:** [October 16, 2020, 11:24am UTC](https://community.traefik.io/t/general-way-to-get-https/8153/4 "2020-10-16T11:24:58Z")

</div>

Closed on October 16, 2020, 11:24am UTC

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