Force https on traefik with docker-compose, mixed content

I'm using traefik as my reverse proxy on my server. It's used to host multiple web applications like wordpress and larvel. For these 2 application i found a "fix" for the mixed(the application servers http assets) content warning, as example, the wordpress fix:

$http_s = ( !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') ? 'https' : 'http';

But I don't really like this solution and not every web-app support the option to declare "https only" or "force https" Is there an option in traefik to force or rewrite the urls, i didnt have these problems with Apache or nginx. I already have an http->https redirection These are my configs: Docker-compose traefik:

    container_name: traefik
    image: traefik:v2.6
    restart: unless-stopped
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.web.address=:80"
      - --entrypoints.websecure.address=:443
      - --entrypoints.websecure.http.tls=true
      - --entrypoints.web.http.redirections.entrypoint.scheme=https
      - --entrypoints.web.http.redirections.entrypoint.permanent=true
      # The HTTP port
      - "80:80"
      - "443:443"
      # The Web UI (enabled by --api.insecure=true)
      - "8080:8080"

Docker-compose web app:

    image: nginx:latest
    container_name: ${APP_NAME}-nginx
      - .env
      - "./config/nginx/:/etc/nginx/templates/"
      - ./src:/var/www/html:rw,cached
      - default
      - traefik
      - "traefik.enable=true"
      - "traefik.http.routers.${APP_NAME}.rule=Host(`${DOMAIN}`)"
      - "traefik.http.routers.${APP_NAME}.entrypoints=websecure"
      - "${APP_NAME}.loadbalancer.server.port=80"
      - ""
    restart: unless-stopped


There is a global redirection configured on entryPoint that should redirect each incoming request from HTTP to HTTPS. So based on my best knowledge it should solve the problem with having mixed content.

Could you please help with understanding your issue?

Thank you,

Yes i enabled the redirect and that works. But only of the initial request. The web-app behind traefik thinks the request is a http request. So it tries to serve all assets with http, so i get a lot of mix content error's(like this


i found a workaround for laravel and for wordpress
as exaple the wordpress workaround:

$http_s = ( !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') ? 'https' : 'http';

I don't had this problem virtual servers with nginx.

You can use a Traefik middleware label to rewrite the X-Forwarded-Proto header, so after removing all the other lines my docker-compose entry looks a little like

image: "traefik:v2.6"
container_name: "traefik"
restart: unless-stopped
- "--entrypoints.http.address=:80"
- "--entrypoints.https.address=:443"
- ""
- "--entrypoints.web.http.redirections.entryPoint.scheme=https"
- "traefik.http.middlewares.sslheader.headers.customrequestheaders.X-Forwarded-Proto=https"

As for why you do not have this issue with nginx, well a default install with settings in place to use nginx as a proxy may have already set usable defaults - such as shown in this article

I tried your config but still it doesn't work. Are there more header i need to forward to get this working?