At home, I have HAProxy terminating TLS for some services running on my server.
What I want is to have a VPS with Traefik act as a front-end to my services hosted at home.
Basically, I am trying to build my own Cloudflare Tunnel without the downside of letting a third-party decrypt traffic.
I want connections to be
Internet --https--> Traefik on VPS (not decrypting traffic) --https--> HAProxy (decrypting traffic) --http--> services
So far,
Internet --https--> HAProxy (decrypting traffic) --http--> services
works well when whoami.mydomain
points to HAProxy. The problem is on Traefik.
TCP router attempt
The only documented TLS passthrough option I see is for TCP routers. Since HTTPS uses TCP, I hope a TCP router can forward HTTPS traffic.
Config files
traefik.yml
entryPoints:
websecure:
address: ":443"
log:
level: DEBUG
providers:
docker:
endpoint: "unix:///var/run/docker.sock"
exposedByDefault: false
filename: /etc/traefik/dynamic_config.yml
certificatesresolvers:
...
dynamic_conf.yml
tcp:
routers:
whoami_rtr_tcp:
rule: "HostSNI(`whoami.mydomain`)"
service: svc_tcp
tls:
passthrough: true
services:
svc_tcp:
loadBalancer:
servers:
- address: "<HAProxy_IP>:443"
Logs
But when I try to access my service, this is what I get
curl -v --resolve whoami.mydomain:443:<VPS_IP> https://whoami.mydomain
* Added whoami.mydomain:443:<VPS_IP> to DNS cache
* Hostname whoami.mydomain was found in DNS cache
* Trying <VPS_IP>:443...
* Connected to whoami.mydomain (<VPS_IP>) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* CAfile: /etc/ssl/certs/ca-certificates.crt
* CApath: /etc/ssl/certs
* TLSv1.0 (OUT), TLS header, Certificate Status (22):
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.0 (OUT), TLS header, Unknown (21):
* TLSv1.3 (OUT), TLS alert, decode error (562):
* error:0A000126:SSL routines::unexpected eof while reading
* Closing connection 0
curl: (35) error:0A000126:SSL routines::unexpected eof while reading
and stops there. The Traefik logs are
{"level":"debug","msg":"Handling TCP connection from <Client_IP>:56670 to <HAProxy_IP>:443","time":"2023-04-30T23:24:00+02:00"}
{"level":"error","msg":"Error while dialing backend: dial tcp <HAProxy_IP>:443: connect: connection timed out","time":"2023-04-30T23:26:00+02:00"}
and stop there.
Does anyone have an idea of how to do this, if it is even possible?
EDIT: I can access the service from the VPS with a curl command, so the problem is really with Traefik.