# Passthrough for http and redirect

**URL:** <https://community.traefik.io/t/passthrough-for-http-and-redirect/15268>\
**Category:** Traefik v2\
**Tags:** file\
**Created:** [July 29, 2022, 7:53am UTC](https://community.traefik.io/t/passthrough-for-http-and-redirect/15268 "2022-07-29T07:53:13Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![n1kt0](https://avatars.discourse-cdn.com/v4/letter/n/d26b3c/32.png) [@n1kt0](https://community.traefik.io/u/n1kt0)\
**Post date:** [July 29, 2022, 7:53am UTC](https://community.traefik.io/t/passthrough-for-http-and-redirect/15268/1 "2022-07-29T07:53:13Z")

</div>

Good afternoon.

For one of the hosts, forward from http to https.  
That is, the site itself has a certificate, while traefik does not use certificates.

error in logs

level=error msg="Error occurred during watcher callback: /traefik/config/custom/host201.srv.xxx.xx.yaml: field not found, node: passthrough" providerName=file

Do I understand correctly that passthrough is used for tcp? How then to be with https?

```auto
traefik info

Version: 2.8.1
Codename: vacherin
Go version: go1.17.11
Built: 2022-07-11T14:06:57Z
OS/Arch: linux/amd64

```

```auto
## Static configuration yaml
entryPoints:
  http:
    address: ":80"
  https:
    address: ":443"
log:
  filePath: "/var/log/traefik.log"
  format: common
  level: DEBUG

accessLog:
  filePath: "/var/log/traefik_access.log"
  format: common
  fields:
    defaultMode: debug

http:
  routers:
    http-catchall:
      rule: hostregexp(`{host:.+}`)
      entrypoints:
      - http
      middlewares:
      - redirect-to-https
  middlewares:
    redirect-to-https:
      redirectScheme:
        scheme: https
        permanent: true

providers:
  file:
    directory: /traefik/config/custom
    watch: true

```

```auto
## Dynamic configuration yaml
http:
  routers:
    host_host201.srv.xxx.xx:
      service: service-host_host201.srv.xxx.xx
      rule: "Host(`host201.srv.xxx.xx`)"
      entryPoints:
      - http
      - https
      tls:
        passthrough: true
  services:
    service-host_host201.srv.xxx.xx:
      loadBalancer:
        servers:
        - url: "https://172.16.16.2"

```

---

<div class="post-metadata">

**Author:** ![bryanpedini](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/bryanpedini/32/5662_2.png) [@bryanpedini](https://community.traefik.io/u/bryanpedini)\
**Post date:** [July 31, 2022, 8:58am UTC](https://community.traefik.io/t/passthrough-for-http-and-redirect/15268/2 "2022-07-31T08:58:47Z")

</div>

Hi,  
Have you tried to redirect to `url: "http://172.16.16.2"` instead of `https`?  
So that HTTP requests will be forwarded as-is and HTTPS request will get redirected to port 443 (I think).

Another solution would be to have two different routers, one listening on the `http` endpoint and redirecting to `http://url` and the other listening on the `https` endpoint and having `passthrough: true` enabled.

---

<div class="post-metadata">

**Author:** ![n1kt0](https://avatars.discourse-cdn.com/v4/letter/n/d26b3c/32.png) [@n1kt0](https://community.traefik.io/u/n1kt0)\
**Post date:** [August 1, 2022, 6:55am UTC](https://community.traefik.io/t/passthrough-for-http-and-redirect/15268/3 "2022-08-01T06:55:00Z")

</div>

2\_bryanpedini thank you for your time.

I just need to redirect http to https while the proxy does not have a certificate.

If you replace url: "[https://172.16.16.2](https://172.16.16.2)" with url: "[http://172.16.16.2](http://172.16.16.2)" then the "field not found, node: passthrough" error remains.  
In this case, even if you go to the address [https://host201.srv.xxx.xx](https://host201.srv.xxx.xx) then "ERR\_TOO\_MANY\_REDIRECTS"

---

<div class="post-metadata">

**Author:** ![n1kt0](https://avatars.discourse-cdn.com/v4/letter/n/d26b3c/32.png) [@n1kt0](https://community.traefik.io/u/n1kt0)\
**Post date:** [August 1, 2022, 1:46pm UTC](https://community.traefik.io/t/passthrough-for-http-and-redirect/15268/4 "2022-08-01T13:46:37Z")

</div>

It turned out to make a redirect and the site opens. But traefik substitutes its certificate instead of the site's certificate.

```auto
http:
  routers:
    host_host201.srv.xxx.xx:
      service: service-host_host201.srv.xxx.xx
      rule: "Host(`host201.srv.xxx.xx`)"
      entryPoints:
      - https
      tls: {}
  services:
    service-host_host201.srv.xxx.xx:
      loadBalancer:
        serversTransport: transport_host201.srv.xxx.xx
        servers:
        - url: https://172.16.16.2
        passHostHeader: true  

  serversTransports: 
    transport_host201.srv.xxx.xx: 
      insecureSkipVerify: true 

```

---

<div class="post-metadata">

**Author:** ![n1kt0](https://avatars.discourse-cdn.com/v4/letter/n/d26b3c/32.png) [@n1kt0](https://community.traefik.io/u/n1kt0)\
**Post date:** [August 2, 2022, 8:17am UTC](https://community.traefik.io/t/passthrough-for-http-and-redirect/15268/5 "2022-08-02T08:17:32Z")

</div>

and nothing.  
https is working, http is not, although there are entrypoints, but the output is an error

`404 page not found`

```auto
tcp:

  routers:
    routes_host201.srv.xxx.xx:
      service: service_host201.srv.xxx.xx
      entryPoints:
      - http 
      - https
      rule: "HostSNI(`host201.srv.xxx.xx`)"
      tls:
        passthrough: true

  services:
    service_host201.srv.xxx.xx:
      loadBalancer:
        servers:
        - address: "172.16.16.2:443"

```

logs

```auto
level=debug msg="Adding Passthrough route for \"HostSNI(`host201.srv.xxx.xx`)\"" entryPointName=https routerName=routes_host201.srv.xxx.xx@file
level=debug msg="Adding Passthrough route for \"HostSNI(`host201.srv.xxx.xx`)\"" entryPointName=http routerName=routes_host201.srv.xxx.xx@file
level=debug msg="Creating TCP server 0 at 172.16.16.2:443" entryPointName=https serverName=0 routerName=routes_host201.srv.xxx.xx@file serviceName=service_host201.srv.xxx.xx
level=debug msg="Creating TCP server 0 at 172.16.16.2:443" entryPointName=http serverName=0 routerName=routes_host201.srv.xxx.xx@file serviceName=service_host201.srv.xxx.xx

```

---

<div class="post-metadata">

**Author:** ![n1kt0](https://avatars.discourse-cdn.com/v4/letter/n/d26b3c/32.png) [@n1kt0](https://community.traefik.io/u/n1kt0)\
**Post date:** [August 3, 2022, 10:44am UTC](https://community.traefik.io/t/passthrough-for-http-and-redirect/15268/6 "2022-08-03T10:44:54Z")

</div>

hi all

I looked at the traffic and this is what happened.  
If I used https then I see how the computer connects to the traefik and then the trajevik connects to the server.  
If you use http, then the computer connects to the traffic and that's it.

---

<div class="post-metadata">

**Author:** ![n1kt0](https://avatars.discourse-cdn.com/v4/letter/n/d26b3c/32.png) [@n1kt0](https://community.traefik.io/u/n1kt0)\
**Post date:** [August 4, 2022, 7:02am UTC](https://community.traefik.io/t/passthrough-for-http-and-redirect/15268/7 "2022-08-04T07:02:41Z")

</div>

Kiitos kaikille.  
Problem solved.

```auto
http:

  routers:
    host_http_host201.srv.xxx.xx:
      service: service-host_http_host201.srv.xxx.xx
      rule: "Host(`host201.srv.xxx.xx`)"
      entryPoints:
      - http

  services:
    service-host_http_host201.srv.xxx.xx:
      loadBalancer:
        servers:
        - url: "http://172.16.10.2"
        passHostHeader: tru
        
tcp:

  routers:
    routes_tcp_host201.srv.xxx.xx:
      service: service_tcp_host201.srv.xxx.xx
      rule: "HostSNI(`host201.srv.xxx.xx`)"
      entryPoints:
      - https
      tls:
        passthrough: true

  services:
    service_tcp_host201.srv.xxx.xx:
      loadBalancer:
        servers:
        - address: "172.16.16.2:443"

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/containo/original/2X/b/bd81ebdb578656e76e56ff3cc3eed021d3ba132d.png) [@system](https://community.traefik.io/u/system)\
**Post date:** [August 7, 2022, 7:03am UTC](https://community.traefik.io/t/passthrough-for-http-and-redirect/15268/8 "2022-08-07T07:03:21Z")

</div>

Closed on August 7, 2022, 7:03am UTC

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
