Skip to main content

HTTP Redirect Using Traefik Reverse Proxy

Enter the following code in the data/traefik_conf.yaml:

http:
  routers:
    svcname:
      entryPoints:
        - "http"
      rule: "Host(`host.domain.tld`)"

      middlewares:
        - "svcname-https-redirect"
      service: svcname

    svcname-secure:
      entryPoints:
        - "https"
      rule: "Host(`host.domain.tld`)"

      tls:
        certResolver: le
      service: svcname

  services:
    svcname:
      loadBalancer:
        servers:
          - url: "http://192.168.xxx.xxx:8080"
        passHostHeader: true

  middlewares:
    svcname-https-redirect:
      redirectScheme:
        scheme: https