Skip to main content

HTTP Redirect Using Traefik Reverse Proxy

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

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

      middlewares:
        - "appharmony-http-svcname-https-redirect"
      service: "external-url"svcname

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

      tls:
        certResolver: le
      middlewares:
        - "appharmony-https-redirect"
      service: "external-url"svcname

  services:
    external-url:svcname:
      loadBalancer:
        servers:
          - url: "https:http://app.azaleahealth.com/login?c=141121"192.168.xxx.xxx:8080"
        passHostHeader: falsetrue

  middlewares:
    appharmony-http-redirect:
      redirectRegex:
        regex: "^http://app.harmonymedical.net/(.*)"
        replacement: "https://app.azaleahealth.com/${1}"

    appharmony-svcname-https-redirect:
      redirectRegex:redirectScheme:
        regex:scheme: "^https://app.harmonymedical.net/(.*)"
        replacement: "https://app.azaleahealth.com/${1}"https