# Global http to https redirect in v2

**URL:** <https://community.traefik.io/t/global-http-to-https-redirect-in-v2/1658>\
**Category:** Traefik v2\
**Tags:** file\
**Created:** [September 18, 2019, 6:01am UTC](https://community.traefik.io/t/global-http-to-https-redirect-in-v2/1658 "2019-09-18T06:01:39Z")\
**Posts on this page:** 1\
**Showing post:** 3

<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:** [September 19, 2019, 11:58am UTC](https://community.traefik.io/t/global-http-to-https-redirect-in-v2/1658/3 "2019-09-19T11:58:08Z")

</div>

The approach is right:

```auto
# traefik.toml
## static configuration

[entryPoints]
  [entryPoints.web]
    address = 80
  [entryPoints.websecure]
    address = 443

[providers.file]
  directory = "/dynamic/"

```

```auto
# /dynamic/redirect.toml
## dynamic configuration

[http.routers]
  [http.routers.redirecttohttps]
    entryPoints = ["web"]
    middlewares = ["httpsredirect"]
    rule = "HostRegexp(`{host:.+}`)"
    service = "noop"

[http.services]
  # noop service, the URL will be never called
  [http.services.noop.loadBalancer]
    [[http.services.noop.loadBalancer.servers]]
      url = "http://192.168.0.1"

[http.middlewares]
  [http.middlewares.httpsredirect.redirectScheme]
    scheme = "https"

```

with Docker:

```auto
version: "3.7"

services:

  traefik:
    image: traefik:v2.1.2
    command:
      - --entrypoints.web.address=:80
      - --entrypoints.websecure.address=:443
      - --providers.docker=true
    ports:
      - 80:80
      - 443:443
    labels:
      traefik.http.routers.http-catchall.rule: hostregexp(`{host:.+}`)
      traefik.http.routers.http-catchall.entrypoints: web
      traefik.http.routers.http-catchall.middlewares: redirect-to-https@docker
      traefik.http.middlewares.redirect-to-https.redirectscheme.scheme: https
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro

```

[https://docs.traefik.io/migration/v1-to-v2/#http-to-https-redirection-is-now-configured-on-routers](https://docs.traefik.io/migration/v1-to-v2/#http-to-https-redirection-is-now-configured-on-routers)

---

_[View the full topic](https://community.traefik.io/t/global-http-to-https-redirect-in-v2/1658)._
