# HTTP -\> HTTPS for a specific URL, only?

**URL:** <https://community.traefik.io/t/http-https-for-a-specific-url-only/2829>\
**Category:** Traefik v2\
**Tags:** docker\
**Created:** [November 6, 2019, 3:29pm UTC](https://community.traefik.io/t/http-https-for-a-specific-url-only/2829 "2019-11-06T15:29:20Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![TrafikJam](https://avatars.discourse-cdn.com/v4/letter/t/b38774/32.png) [@TrafikJam](https://community.traefik.io/u/TrafikJam)\
**Post date:** [November 6, 2019, 3:29pm UTC](https://community.traefik.io/t/http-https-for-a-specific-url-only/2829/1 "2019-11-06T15:29:20Z")

</div>

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](https://github.com/jwilder/nginx-proxy/issues/1340)

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

> <https://github.com/containous/traefik/issues/5772>
>
> Slightly more verbose way to ask: Is there any way to make Traefik not forward HTTP -\> HTTPS for a specific...

---

<div class="post-metadata">

**Author:** ![ldez](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/ldez/32/5_2.png) [@ldez](https://community.traefik.io/u/ldez)\
**Post date:** [November 6, 2019, 5:23pm UTC](https://community.traefik.io/t/http-https-for-a-specific-url-only/2829/2 "2019-11-06T17:23:48Z")

</div>

Hello,

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.

---

<div class="post-metadata">

**Author:** ![TrafikJam](https://avatars.discourse-cdn.com/v4/letter/t/b38774/32.png) [@TrafikJam](https://community.traefik.io/u/TrafikJam)\
**Post date:** [November 6, 2019, 5:37pm UTC](https://community.traefik.io/t/http-https-for-a-specific-url-only/2829/3 "2019-11-06T17:37:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ldez](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/ldez/32/5_2.png) [@ldez](https://community.traefik.io/u/ldez)\
**Post date:** [November 6, 2019, 5:39pm UTC](https://community.traefik.io/t/http-https-for-a-specific-url-only/2829/4 "2019-11-06T17:39:26Z")

</div>

letsencrypt can me managed by traefik it-self [https://docs.traefik.io/v2.0/https/acme/](https://docs.traefik.io/v2.0/https/acme/)

> **[Traefik 2.0 & Docker 101](https://blog.containo.us/traefik-2-0-docker-101-fc2893944b9d)**
>
> Tips & Tricks the Documentation Doesn’t Tell You

---

<div class="post-metadata">

**Author:** ![TrafikJam](https://avatars.discourse-cdn.com/v4/letter/t/b38774/32.png) [@TrafikJam](https://community.traefik.io/u/TrafikJam)\
**Post date:** [November 14, 2019, 2:47pm UTC](https://community.traefik.io/t/http-https-for-a-specific-url-only/2829/5 "2019-11-14T14:47:09Z")

</div>

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 VIRTUAL\_HOST=[thedomainname.com](http://thedomainname.com) for traefik? It makes it quite easy & nice to run multiple webserver on the same host within containers.  
Thanks again!

---

<div class="post-metadata">

**Author:** ![dduportal](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/dduportal/32/4_2.png) [@dduportal](https://community.traefik.io/u/dduportal)\
**Post date:** [November 14, 2019, 3:41pm UTC](https://community.traefik.io/t/http-https-for-a-specific-url-only/2829/6 "2019-11-14T15:41:57Z")

</div>

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: [https://docs.traefik.io/v2.0/getting-started/install-traefik/#use-the-official-docker-image](https://docs.traefik.io/v2.0/getting-started/install-traefik/#use-the-official-docker-image) . 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.

---

<div class="post-metadata">

**Author:** ![TrafikJam](https://avatars.discourse-cdn.com/v4/letter/t/b38774/32.png) [@TrafikJam](https://community.traefik.io/u/TrafikJam)\
**Post date:** [February 12, 2020, 8:05am UTC](https://community.traefik.io/t/http-https-for-a-specific-url-only/2829/7 "2020-02-12T08:05:06Z")

</div>

OK, mostly done switching over to Traefik from Nginx. Now how do I rewrite [http://mydomain.com/specificURL1](http://mydomain.com/specificURL1) from container A, to [https://service.mydomain.com/specificURL2](https://service.mydomain.com/specificURL2) which is in container B?

---

<div class="post-metadata">

**Author:** ![TrafikJam](https://avatars.discourse-cdn.com/v4/letter/t/b38774/32.png) [@TrafikJam](https://community.traefik.io/u/TrafikJam)\
**Post date:** [February 13, 2020, 7:35pm UTC](https://community.traefik.io/t/http-https-for-a-specific-url-only/2829/8 "2020-02-13T19:35:25Z")

</div>

The solution must be compatible with:

```auto
      # 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.

---

<div class="post-metadata">

**Author:** ![TrafikJam](https://avatars.discourse-cdn.com/v4/letter/t/b38774/32.png) [@TrafikJam](https://community.traefik.io/u/TrafikJam)\
**Post date:** [February 13, 2020, 10:31pm UTC](https://community.traefik.io/t/http-https-for-a-specific-url-only/2829/9 "2020-02-13T22:31:13Z")

</div>

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='.

```auto
- "traefik.http.middlewares.PP-redirect.replacepathregex.regex=^http://www.domain.com/oldURL"
- "traefik.http.middlewares.PP-redirect.replacepathregex.replacement=http://services.domain.com/new"

```

I've tried these as labels in the service running "[http://www.domain.com/oldURL](http://www.domain.com/oldURL)" the service running "[http://services.domain.com/new](http://services.domain.com/new)" - 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.

---

<div class="post-metadata">

**Author:** ![TrafikJam](https://avatars.discourse-cdn.com/v4/letter/t/b38774/32.png) [@TrafikJam](https://community.traefik.io/u/TrafikJam)\
**Post date:** [February 20, 2020, 11:24pm UTC](https://community.traefik.io/t/http-https-for-a-specific-url-only/2829/10 "2020-02-20T23:24:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ldez](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/ldez/32/5_2.png) [@ldez](https://community.traefik.io/u/ldez)\
**Post date:** [February 21, 2020, 12:38am UTC](https://community.traefik.io/t/http-https-for-a-specific-url-only/2829/11 "2020-02-21T00:38:25Z")

</div>

> **[Contact Sales | Containous](https://info.containo.us/contact-sales)**
>
> Need to contact the sales team? Fill out the form and we'll be in touch shortly

---

<div class="post-metadata">

**Author:** ![TrafikJam](https://avatars.discourse-cdn.com/v4/letter/t/b38774/32.png) [@TrafikJam](https://community.traefik.io/u/TrafikJam)\
**Post date:** [February 22, 2020, 9:49am UTC](https://community.traefik.io/t/http-https-for-a-specific-url-only/2829/12 "2020-02-22T09:49:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![TrafikJam](https://avatars.discourse-cdn.com/v4/letter/t/b38774/32.png) [@TrafikJam](https://community.traefik.io/u/TrafikJam)\
**Post date:** [February 25, 2020, 12:28am UTC](https://community.traefik.io/t/http-https-for-a-specific-url-only/2829/13 "2020-02-25T00:28:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![TrafikJam](https://avatars.discourse-cdn.com/v4/letter/t/b38774/32.png) [@TrafikJam](https://community.traefik.io/u/TrafikJam)\
**Post date:** [March 10, 2020, 3:24pm UTC](https://community.traefik.io/t/http-https-for-a-specific-url-only/2829/14 "2020-03-10T15:24:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ldez](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/ldez/32/5_2.png) [@ldez](https://community.traefik.io/u/ldez)\
**Post date:** [March 10, 2020, 3:30pm UTC](https://community.traefik.io/t/http-https-for-a-specific-url-only/2829/15 "2020-03-10T15:30:40Z")

</div>

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

> **[HTTP -\> HTTPS for a specific URL, only?](https://community.traefik.io/t/http-https-for-a-specific-url-only/2829/2)**
>
> Hello, 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.

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

---

<div class="post-metadata">

**Author:** ![TrafikJam](https://avatars.discourse-cdn.com/v4/letter/t/b38774/32.png) [@TrafikJam](https://community.traefik.io/u/TrafikJam)\
**Post date:** [March 10, 2020, 3:32pm UTC](https://community.traefik.io/t/http-https-for-a-specific-url-only/2829/16 "2020-03-10T15:32:22Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![ldez](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/ldez/32/5_2.png) [@ldez](https://community.traefik.io/u/ldez)\
**Post date:** [March 10, 2020, 3:36pm UTC](https://community.traefik.io/t/http-https-for-a-specific-url-only/2829/17 "2020-03-10T15:36:18Z")

</div>

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

Working sample:

```auto
  traefik:
    # ...

    labels:
    # ...

    # 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

    # ...

  myapp:
    labels:
    # ...

    traefik.http.routers.app.rule: host(`yourdomain.com`)
    traefik.http.routers.app.entrypoints: web
    traefik.http.routers.app.priority: 100000000000000000000

    # ...
```

---

<div class="post-metadata">

**Author:** ![TrafikJam](https://avatars.discourse-cdn.com/v4/letter/t/b38774/32.png) [@TrafikJam](https://community.traefik.io/u/TrafikJam)\
**Post date:** [March 10, 2020, 3:52pm UTC](https://community.traefik.io/t/http-https-for-a-specific-url-only/2829/18 "2020-03-10T15:52:41Z")

</div>

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

```auto
services:
    container_name: Services
    restart: always
    ports:
      - "2001:2001"
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.services.rule=Host(`services.URL.com`)"
      - "traefik.http.routers.services.entrypoints=websecure"
      - "traefik.http.routers.services.middlewares=services@docker,redirect"
      - "traefik.http.middlewares.services.compress=true"
      - "traefik.http.routers.services.tls.certresolver=le"
      - "traefik.http.routers.services.tls=true"
      - "traefik.http.services.services.loadbalancer.server.port=2001"
      - "traefik.http.middlewares.redirect.replacepathregex.regex=^http://www.URL.com/path/123"
      - "traefik.http.middlewares.redirect.replacepathregex.replacement=https://services.URL.com/456"

```

"[https://services.URL.com/456](https://services.URL.com/456)" does not receive the POST sent to "[http://www.URL.com/path/123](http://www.URL.com/path/123)" - however, I see a 200 in Traefik.  
Also, this will not allow "[https://services.URL.com/456](https://services.URL.com/456)" 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 [www.URL.com](http://www.URL.com) & [URL.com](http://URL.com), 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).

---

<div class="post-metadata">

**Author:** ![TrafikJam](https://avatars.discourse-cdn.com/v4/letter/t/b38774/32.png) [@TrafikJam](https://community.traefik.io/u/TrafikJam)\
**Post date:** [March 10, 2020, 10:05pm UTC](https://community.traefik.io/t/http-https-for-a-specific-url-only/2829/19 "2020-03-10T22:05:32Z")

</div>

@ldez 🙏 I hope that's enough info

---

<div class="post-metadata">

**Author:** ![ldez](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/ldez/32/5_2.png) [@ldez](https://community.traefik.io/u/ldez)\
**Post date:** [March 10, 2020, 10:27pm UTC](https://community.traefik.io/t/http-https-for-a-specific-url-only/2829/20 "2020-03-10T22:27:52Z")

</div>

The router is on `services.URL.com` so it will never catch `http://www.URL.com/path/123`.

You have to create a router that match the host `www.URL.com`.

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`.

```auto
services:
  my_app:
    image: myimage
    container_name: my_app
    restart: always
    labels:
      - "traefik.enable=true"

      # router for services.URL.com on the entrypoint websecure
      # https://services.URL.com
      - "traefik.http.routers.app.rule=Host(`services.URL.com`)"
      - "traefik.http.routers.app.entrypoints=websecure"
      - "traefik.http.routers.app.middlewares=comp"
      - "traefik.http.routers.app.tls=true"
      - "traefik.http.routers.app.tls.certresolver=le"

      - "traefik.http.services.app_svc.loadbalancer.server.port=2001"

      # router for http://www.URL.com on the entrypoint web, always redirect.
      # https://www.URL.com/path/123 -> https://services.URL.com/456
      - "traefik.http.routers.app_redirect.rule=Host(`www.URL.com`) && 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=^http://www.URL.com/path/123"
      - "traefik.http.middlewares.redirect.redirectregex.replacement=https://services.URL.com/456"

```

[Next page](https://community.traefik.io/t/http-https-for-a-specific-url-only/2829.md?page=2)
