I swear I have tried every conceivable configuration from the docs and github. All I want is a simple redirect so http requests to my service get automatically turned into https. This was working fine in v1, but of course it's broken for v2.
There a apparently a million ways to do this, because no two examples I've seen are the same, and none of them worked for me. Maybe i'm missing something.
At first http requests would result in a 404 error, but after some tinkering the http requests go through, but they are not redirected.
Here are the relevant configs in my docker-compose.yaml:
traefik:
image: "traefik:v2.0.2"
container_name: "traefik"
command:
- "--log.level=DEBUG"
- "--api.insecure=true"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
- "--entrypoints.websecure.address=:443"
- "--certificatesresolvers.mytlschallenge.acme.tlschallenge=true"
#- "--certificatesresolvers.mytlschallenge.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory"
- "--certificatesresolvers.mytlschallenge.acme.email=me@myemail.com"
- "--certificatesresolvers.mytlschallenge.acme.storage=/letsencrypt/acme.json"
ports:
- "80:80"
- "8081:8081"
- "443:443"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "$HOME/Data/Programs/Docker/TraefikV2/letsencrypt:/letsencrypt"
#- "./traefik.toml:/traefik.toml"
networks:
- traefik
restart: unless-stopped
labels:
# Global redirection: http to https
#- "traefik.http.routers.http-catchall.rule=HostRegexp(`{host:(www\\.)?.+}`)"
#- "traefik.http.routers.http-catchall.entrypoints=web"
#- "traefik.http.routers.http-catchall.middlewares=wwwtohttps"
# Global redirection: https (www.) to https
#- "traefik.http.routers.wwwsecure-catchall.rule=HostRegexp(`{host:(www\\.).+}`)"
#- "traefik.http.routers.wwwsecure-catchall.entrypoints=websecure"
#- "traefik.http.routers.wwwsecure-catchall.tls=true"
#- "traefik.http.routers.wwwsecure-catchall.middlewares=wwwtohttps"
# middleware: http(s)://(www.) to https://
#- "traefik.http.middlewares.wwwtohttps.redirectregex.regex=^https?://(?:www\\.)?(.+)"
#- "traefik.http.middlewares.wwwtohttps.redirectregex.replacement=https://$${1}"
#- "traefik.http.middlewares.wwwtohttps.redirectregex.permanent=true"
#
- "traefik.http.routers.http-catchall.rule=hostregexp(`{host:.+}`)"
- "traefik.http.routers.http-catchall.entrypoints=web"
- "traefik.http.routers.http-catchall.middlewares=redirect-to-https@docker"
- "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
jellyfin:
image: linuxserver/jellyfin
container_name: jellyfin
environment:
- PUID=1000
- PGID=1000
- TZ=America/Los_Angeles
volumes:
- /home/me/Data/Programs/Docker/Jellyfin/ProgramData/:/config
- /home/me/Data/Media/TV/:/data/tvshows
- /home/me/Data/Media/Movies/:/data/movies
- /home/me/Data/Media/Music/:/data/music
- /home/me/Data/Media/Books/:/data/books
ports:
- 8096:8096
labels:
- "traefik.enable=true"
- "traefik.http.routers.jellyfin.rule=Host(`www.jellyfin.mydomain.com`)"
- "traefik.http.routers.jellyfin.entrypoints=websecure"
- "traefik.http.routers.jellyfin.tls.certresolver=mytlschallenge"
- "traefik.http.middlewares.jellyfin.redirectscheme.scheme=https"
###
#- "traefik.http.middlewares.jellyfin-redirect-websecure.redirectscheme.scheme=https"
- "traefik.http.routers.jellyfin-http.rule=Host(`www.jellyfin.mydomain.com`) || Host(`www.jellyfin.mydomain.com)"
- "traefik.http.routers.jellyfin-http.entrypoints=http"
- "traefik.http.routers.jellyfin-https.rule=Host(`www.jellyfin.mydomain.com`) || Host(`www.jellyfin.mydomain.com`)"
- "traefik.http.routers.jellyfin-http.entrypoints=https"
- "traefik.http.routers.jellyfin-http.middlewares=jellyfin-redirect"
- "traefik.http.middlewares.jellyfin-redirect.redirectscheme.scheme=https"
networks:
- traefik
restart: unless-stopped
Everything that's commented out are things I have tried unsucsessfully. I don't know if I need a combination of these labels or what, but nothing I try has worked.
Another post I saw on this topic got answered with this link Global http to https redirect in v2
but I was not able to find a working solution there