Hi Willy, On Thu, Oct 6, 2011 at 9:54 PM, Willy Tarreau <w...@1wt.eu> wrote:
> Hi Sagi, > > On Thu, Oct 06, 2011 at 04:40:41PM +0200, Sagi Bashari wrote: > > 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)) { > > You're prefectly right, I overlooked this when I did the patch. > > Could you please send me a patch against 1.5-dev ? I'll apply it to > both 1.5 and 1.4. > > Patch against 1.5-dev is attached. I ran a quick test against both 1.5-dev and 1.4.18 and it seems to work fine. Regards, Sagi
forwardfor-if-none.patch
Description: Binary data