Multiple levels of redirects do not work

just plain ol' not working.

Global HTTPS redirect works. but not example.com > www.example.com

here is traefik config:

version: "3.3"
networks:
  public:
    external: true
services:
  traefik:
    image: "traefik:v2.9"
    command:
      - "--log.level=DEBUG"
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--providers.docker.swarmMode=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.web.address=:80"
      - "--entrypoints.web.http.redirections.entrypoint.to=websecure"
      - "--entrypoints.web.http.redirections.entrypoint.scheme=https"
      - "--entryPoints.websecure.address=:443"
      - "--providers.docker.network=public"
    labels:
      - "traefik.http.routers.redirect-router.middlewares=redirect-regex"
      - "traefik.http.middlewares.redirect-regex.redirectregex.regex=^https://example.com/(.*)"
      - "traefik.http.middlewares.redirect-regex.redirectregex.replacement=https://www.example.com/$${1}"

    ports:
      - "80:80"
      - "443:443"
      - "8080:8080"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
    networks:
      public:
        aliases:
          - traefik
    deploy:
      mode: global

and example.com / www.example.com service

version: "3.8"
networks:
  public:
    external: true
services:
  nginx:
    image: "nginx:stable-alpine"
    deploy:
      <<: *default_deploy
      labels:
        - "traefik.enable=true"
        - "traefik.http.routers.nginx.rule=Host(`example.com`) || Host(`www.example.com`)"
        - "traefik.http.routers.nginx.entrypoints=websecure"
        - "traefik.http.routers.nginx.tls.certresolver=default"
        - "traefik.http.services.nginx.loadbalancer.server.port=80"
        - "traefik.http.routers.nginx.tls=true"
        - "traefik.docker.network=public" 
    networks:
      public:
        aliases:
          - nginx

Global HTTPS redirect works. but not example.com > www.example.com

I read here (Redirecting to an external domain with traefik | Jens Knipper) that "multiple levels of redirects do not work. If you also want to do a global https-redirect and www redirect for your domain you are not able to do both". Is this true, please dear god, say it isn't so.

Use 3 backticks before and after code/config to make it readable, in yaml every space matters.

The simple Traefik example has a www to non-www example, that works.

as I said it's not working, have you any experience in this, can you share anything the works for you?

thanks for tip on backticks, i did try that at first but did not see any preview and then searched for the blockquote button

you say the example works, i have tried, does it work with global https redirect, is it setup in my code as it should be:

thanks and best regards,

When using

you need to place labels under compose deploy section (doc).

thank you, your github page got me going :pray:

I noticed it is for traefik 3, but got it going on 2.

Is there a release date for 3?

No one knows, we expect it soon :laughing: