How to redirect http non-www to https www?

Hi all,

I'm new from nginx, I want to redirect http non-www to https www.

Example:     -> ->    ->

Thank for your help!

Which traefik version are you using 1.7.x or 2.2.x ?

I'm using Traefik 2.2.x

This example uses Labels because i mostly use traefik with docker labels.
This is just simple http 2 https forwarding for your www subdomain you have to deal with regex and some pathfrefix mappers or stuff like that i think.

  • i use 2 entrypoints
    • web:80
    • websecure:443 web redirect@file Host(``) websecure true 8080 Host(``)
  • web uses middleware "redirect@file" this middleware is defined in my dynamic_conf.toml
# redirect
    scheme = "https"
    permanent = true
  • dynamic_conf.toml is refernced in my (static) traefik.toml:
    filename = "<traefik_path>/dynamic_conf.toml"

hope this helps