-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Caddy not setting PROXYv2 TLV fields in reverse_proxy mode #5967
Comments
The PR to replace the lib was influenced by the need to accept connections with TLVs, not adding TLVs for upstreams. It appears to be trivial to add TLVs to the header. The only tricky part is translating the binary "value" (byte) to a decent UI/UX in the Caddyfile and JSON. If you can help me with that, I can try squeezing this requirement into the PR. Do you have any imagination of the UX to set TLVs? |
Hello @mohammed90, thanks for taking a look at my issue :). For my needs I don't think we need to be able to set TLV attributes in the configuration file, instead they should be populated based on the request that came in to Caddy. For example, looking at https://www.haproxy.org/download/2.3/doc/proxy-protocol.txt it states:
I am not very familiar with the Caddy codebase so apologies if I am missing something, but there appears to be a caddy/modules/caddyhttp/reverseproxy/hosts.go Lines 242 to 246 in 4173e2c
And this is populated at
Maybe the struct could be extended with a I have spent some time looking at the new proxyproto lib and while I cant find a "
|
If we agree on the general direction of the solution I could probably look into opening a PR for adding this to Caddy as well. Of course it would be nice if the WIP to migrate to the new lib could be merged before that :). |
I don't understand why this is needed. Caddy's proxy already passes through X-Forwarded-Proto correctly: https://caddyserver.com/docs/caddyfile/directives/reverse_proxy#defaults |
If I am to set things up so HTTPS traffic passes through Caddy and is proxied to Varnish I know Caddy will protect X-Forwarded-Proto from client manipulation, but given that ordinary HTTP traffic is going directly to Varnish there is nothing protecting headers, so a client could set it to "https" or something else for such traffic. If I can check a TLV attribute to tell if the request came in via TLS then I can trust this is correct since a client would not be able to set the contents of the proxy protocol header. If I don't have access to that I will need to fall back to checking ports to decide if a given header can be considered safe or not. It also appears to me there is potentially more information available in TLV attributes than then protected headers which can be usable in the backend system. |
Hello,
I am attempting to use Caddy for TLS termination in front of a Varnish cache server.
The configuration for hooking up Caddy to Varnish looks like this:
The traffic flow works well, but then I wanted to be able to set headers in Varnish based on TLV attributes in the PROXYv2 packets, looking something like this:
This is using the Varnish
vmod_proxy
to read TLV values: https://varnish-cache.org/docs/trunk/reference/vmod_proxy.html.I then noticed that Caddy does not appear to set such values, and based on mastercactapus/proxyprotocol#3 it looks like the currently used proxy protocol library does not support setting them either. I have also seen that there appears to be WIP to start using another proxy protocol lib in #5915.
From what I can tell even if the latter PR is merged this would still not set TLV fields, would it make sense to add such code?
The text was updated successfully, but these errors were encountered: