HTTP -> HTTPS for a specific URL, only?

Slightly more verbose way to ask: Is there any way to make Traefik not forward HTTP -> HTTPS for a specific URL, only (while continuing to forward the rest to HTTPS)?

I'm going to switch from nginx if I can do this on traefik. Do you know if it is possible? And if so, then how? I've been trying with nginx here: jwilder/nginx-proxy#1340

I saw told by your GitHub bot to ask here in the forum instead:


yes it's possible.

Just need to create a router with an entry point on the port 80 and set a priority if needed.

It's hard to say more without any concrete context.

(post withdrawn by author, will be automatically deleted in 1 hour unless flagged)

letsencrypt can me managed by traefik it-self

Is there a traefik docker-compose.yml you recommend that is widely used and supported?
Not many seem to be using traefik-library-image (on github) in comparison to jwilder's nginx-proxy - any idea why? Maybe the primary recommendation for traefik is not to run in docker, but on the host? Also, do you know the equivalent of for traefik? It makes it quite easy & nice to run multiple webserver on the same host within containers.
Thanks again!

Hi @TrafikJam, first of all, Traefik has an official Docker image, which the recommended way to run it when using Docker. You can find more on the documentation: . The Github repository you mention, traefik-library-image is absolutely not aimed to be used by end users: it's the source of truth for the official Docker Image.

There is no docker-compose.yml that would work out of the box for you, as the context is different for each user. You strongly should take time to read the blog post mentioned earlier, and/or the official documentation to fully understand how it works.

1 Like

OK, mostly done switching over to Traefik from Nginx. Now how do I rewrite from container A, to which is in container B?

The solution must be compatible with:

      # global redirect to https
      - "traefik.http.routers.http-catchall.rule=hostregexp(`{host:.+}`)"
      - "traefik.http.routers.http-catchall.entrypoints=web"
      - "traefik.http.routers.http-catchall.middlewares=redirect-to-https"

      # middleware redirect
      - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"

which is working well for me overall.

EDIT: to be extra clear - this needs to be a rewrite, only server-side, not client side, will work.

OK, I put in another few hours trying to figure this out. I see the POST on the URL, but it doesn't make its way to the right services somehow. I've tried using internal container@docker and also external URLs as the 'traefik.http.middlewares.old.replacepathregex.replacement='.

- "traefik.http.middlewares.PP-redirect.replacepathregex.regex=^"
- "traefik.http.middlewares.PP-redirect.replacepathregex.replacement="

I've tried these as labels in the service running "" the service running "" - and also both simultaneously. I've also tried it in the global config... And it does still seem like I would have to disable the global HTTPS redirect.

@dduportal @ldez Is there any way to pay for support on this issue? It is really holding me up.
Thank you.

Turns out I cannot afford TraefikEE for $5k/yr :frowning:
I'm testing some router priority settings now...

It seems the request does not get to the right container. The URL POSTs, but not on the right container@docker. It says "-" instead.

Pretty disappointed about this. I thought the forum would have more than one or two people capable of answering such questions. I regret the time switching from nginx to traefik not realizing traefik refuses to even clarify terminology about its functionality. And directed to get support for way more than I can afford... Of course with no guarantee the problem would get solved.

EDIT: I have figured out the nginx config that I want to translate into traffic terms.

the solution of the initial issue (skip the rediection for a specific URL) is here:

  • set a low priority on the global redirect.
  • then set a high priority on the "HTTP only" router

It doesn't work. I get 200s but the service never receives it.
How can I receive on HTTP by a backend service running on HTTPS, and then have it answer on HTTP again?

If you provide more concrete context (docker-compose file), the answer will be more precise.

Working sample:

    # ...

    # ...

    # global redirect to https
    traefik.http.routers.http-catchall.rule: hostregexp(`{host:.+}`)
    traefik.http.routers.http-catchall.entrypoints: web
    traefik.http.routers.http-catchall.middlewares: redirect-to-https
    # traefik.http.routers.http-catchall.priority: 1

    # ...

    # ... host(``) web 100000000000000000000

    # ...

Sure, and I can paste the entire compose file if needed:

    container_name: Services
    restart: always
      - "2001:2001"
      - "traefik.enable=true"
      - "``)"
      - ""
      - ",redirect"
      - ""
      - ""
      - ""
      - ""
      - "traefik.http.middlewares.redirect.replacepathregex.regex=^"
      - "traefik.http.middlewares.redirect.replacepathregex.replacement="

"" does not receive the POST sent to "" - however, I see a 200 in Traefik.
Also, this will not allow "" to reply to the remote without SSL.
So Traefik needs to sit between it and the remote and remove the SSL somehow.

This is not the only app in the compose file. Another app listens on &, but I'm not sure if that matters (I tried this replacepath as a label on both apps, either app, and also globally under traefik app).

@ldez :pray: I hope that's enough info

The router is on so it will never catch

You have to create a router that match the host

Sorry but what you are trying to do is not clear.

So I will give you an example related to what I understand.

I renamed the elements in your sample, because uses the name services for everything is a really confusing.

Also you don't need to export the port 2001.

    image: myimage
    container_name: my_app
    restart: always
      - "traefik.enable=true"

      # router for on the entrypoint websecure
      - "``)"
      - ""
      - ""
      - ""
      - ""

      - ""

      # router for on the entrypoint web, always redirect.
      # ->
      - "traefik.http.routers.app_redirect.rule=Host(``) && PathPrefix(`/path/123`)"
      - "traefik.http.routers.app_redirect.entrypoints=web"
      - "traefik.http.routers.app_redirect.middlewares=redirect"

      # Middlewares defintions

      - "traefik.http.middlewares.comp.compress=true"
      - "traefik.http.middlewares.redirect.redirectregex.regex=^"
      - "traefik.http.middlewares.redirect.redirectregex.replacement="