Hi,

I believe I have found a bug in HAProxy v1.4.18.

The if-none directive of the forwardfor option always looks for the
X-Forwarded-For header, even if an alternative header name was set.

This means that if I use something like:
options forwardfor header X-Client-IP if-none

Then if the client sends its own X-Client-IP header, the client IP will be
appended, and if an X-Forwarded-For header is sent then no X-Client-IP
header will be added.

The expected behavior is to only add the X-Client-IP header if the client
did not send such header himself.

I did not test it, but I think the following will fix this:
Replace src/proto_http.c line 3479:
http_find_header2("X-Forwarded-For", 15, txn->req.sol, &txn->hdr_idx, &ctx))
{

with:
http_find_header2(s->be->fwdfor_hdr_name, s->fe->fwdfor_hdr_len,
txn->req.sol, &txn->hdr_idx, &ctx)) {

Regards,
Sagi

Reply via email to