-
-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[solved] Intermittent tls failures when sharing tls data between caddy and caddy-l4 #293
Comments
I'm experiencing similar issues here, even though my reverse proxy is shared with an SSH backend. Here is my config:
Here is the output; some data, such as hostname and IP, have been redacted. curl output working:
caddy logs, working:
curl output NOT working:
caddy logs for the above, NOT working:
Same issue with my SSH backend.
caddy logs:
NOT working:
caddy logs:
I tried building from source with different versions of Caddy (e.g., v2.8 and v2.9) and even rolling back several commits in this repo, but the result remains the same. |
@blob42 First of all, if you are only interested in DoH, you don't need caddy-l4 at all. As per RFC 8484, DoH provides for pure GET/POST requests to https://example.com/dns-query. And Caddy has all the required features to catch such requests and reverse proxy them to whatever backend you like.
Secondly, the config you provided makes Caddy and caddy-l4 listen to tcp/443. I guess it may be the reason for your config working half of the time. The basic principle is only one service should be listening to a protocol/port at a time. And if you insist on using caddy-l4 (in case you would like to multiplex non-https traffic on the same port, it's the only way currently possible), you need a listener wrapper.
@colrack Same for you. Caddy and caddy-l4 can't listen to tcp/443 at the same time. Please use the listener wrapper mode instead. For both of you, this is what works fine in your cases:
Last but not least, please, be advised that there is no listener wrapper for UDP (yet), so HTTP3 a.k.a QUIC connections will always return OK in the example above. |
@vnxme Thanks for the reply. I will try the listener wrapper way and update the issue if I can solve it. For more context to your reply: If I dont use caddy-l4 and pass the traffic directly to dnscrypt-server + DoH I loose all spam control capabilities on the original connection. I cannot see the origin IP in the filter that you see on my l4 Caddyfile. My downstream caddy only sees connections from DoH. For info the whole https traffic has to pass through dnscrypt server See my issue on dnscrypt-server here |
Now it works for me. |
Thanks @vnxme I can confirm the I couldn't find much details in the docs about what listener_wrapper really does, is there a documentation somewhere that explains what the directive does and how to use ? |
@blob42 Well, I agree that there could be more documentation, and we welcome any related PRs. You can find a general description of listener wrappers here. If you compile Caddy with caddy-l4, you have |
@vnxme Many thanks. |
I am using caddy (caddy docker proxy) + caddy-l4 with dnscrypt-server to do dns over https.
The caddy-l4 captures all https traffic and redirects it to dnscrypt-server to do the DoH splitting, which then forwards https traffic to the caddy proxy that handles all sites.
Both caddy-l4 and caddy-proxy run on their own docker container. I mounted the same
/data/
dir for both containers, thinking that the certificates can be reused for the tls handshake.I am building caddy-l4 with xcaddy.
Problem:
Connecting to my websites over https intermittently fails in a random way. It seems that sometimes the certificate is indeed retrieved from the
/data/
directory where they are stored and the tls handshake succeeds. Half the time the tls connection fails without much details in the logs.HTTPS Traffic ---> L4(443) ---> dnscrypt-server (Forward HTTPS) -----> Caddy Proxy
Automatic HTTPS works perfectly if I let the proxy handle the https traffic directly.
All websites with automatic https are handled on the main caddy proxy and I am only using l4 to catch https traffic and redirect it to dnscrypt-server and doing some custom sni matching to filter traffic.
My L4 Caddyfile
LOGS
curl -L git.blob42.xyz
randomly fails or succeedsSuccessful connection
Failing connection
Let me know how I can help provide more relevant logs or details.
The text was updated successfully, but these errors were encountered: