I have a public facing HAProxy and let Caddy terminate tls on the backends. HAproxy forwards the challenge via http to caddy and forwards tcp requests to backend. Everything is working fine so far, except that i only see the HAProxy ip as client IPs in the caddy logs.
So I want to make use of the proxy_protocol (v2) and activated this for my caddy backends in the HAProxy config but i still struggle to get my caddy config right to make use of it.
Can someone help me explain what i do wrong here in my caddy file and give me a proper example so i finally understand my fault?
So its a global setting?
Unfortunately i still get the HAProxy IP as client IP. I assume thats because this is a TCP forward and i still need to parse the proxy protocol info that HAProxy sends somehow?
I begin to think that might not be possible without compiling layer4 support into Caddy?
If thats the case i would still be very thankful for an explanation about the other proxy_protocol references in the docs and when to use them.
Do i need to explicit define also a deny rule or isn’t that necessary and everything else except will be denied by default if i specify single allow ips?
Also, how would i specify the protocol in use v1/v2 ?
Thank you again so much! I just wasn’t able to see this anymore for hours…
Edit: I just read again and figured my first question is answered with the fallback policy definition.
As soon as the receiver sees “PROXY”, it knows it’s v1. Otherwise, if it sees a specific 12-byte sequence, it knows it’s v2.
You can find more details in the proxy protocol specification:
Edit: To clarify though, when you want Caddy to send the PROXY protocol headers, meaning when Caddy is the sender, acting as a proxy, you do specify which PROXY protocol version Caddy should use.
In other words:
Caddy as a receiver: auto-detects based on the header.
Caddy as a sender: you configure the version explicitly.