1

After reading the github issues related to this with a bunch of loose snippets, It's still completely unclear how to write simple 301 redirects in Traefik as I used to do in nginx like this:

server_name foo.com
return 301 https://bar.com

The plan is: redirect any request in http-scheme to https (same domain), regardless whether the domain exists or not like in nginx default host on port 80 with redirect 301 https://$host. Then, matching the https-Host, return a redirect code with the new Location: - Header.

My base traefik.toml is:

defaultEntryPoints = ["http", "https"]

[entryPoints]
  [entryPoints.http]
  address = ":80"
    [entryPoints.http.redirect]
      entryPoint = "https"
  [entryPoints.https]
  address = ":443"
    [entryPoints.https.tls]
      minVersion = "VersionTLS12"

[acme]
  email = "[email protected]"
  storage = "/etc/traefik/acme/acme.json"
  entryPoint = "https"
  onHostRule = true

[acme.httpChallenge]
  entryPoint = "http"

[file]
  directory = "/etc/traefik/conf/"
  watch = true

Now, how does a file in conf/ must look like to adopt the above nginx redirect? It's about ~300 domains which are hosted at another place, so no backend needed, and it must not be 302/rewrites to be SEO-conform.

This pr https://github.com/containous/traefik/pull/2570 seems to be near to what I want, but there's no documentation how to use it.

4
  • additional info: every domain has a specific counterpart, mostly just another TLD endings.
    – sgohl
    Commented Jun 20, 2018 at 17:09
  • and I'm not sure about the onHostRule and what it actually does mean
    – sgohl
    Commented Jun 20, 2018 at 17:11
  • did you find an answer to this problem? i'm in the same situation, need to enter 100s of 301 rules, and not sure of best method
    – baku
    Commented Dec 1, 2018 at 22:00
  • no, still no solution, hence I'm still stuck with nginx and certbot, too.
    – sgohl
    Commented Dec 16, 2018 at 18:48

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.