POST x-forwarded-for

Alex F alex at
Thu Jun 24 10:45:00 CEST 2010


I'm trying to make varnish forward the IP of the request to the backend.
While I have succeeded in doing so with GET requests, I cannot do the 
same with POST requests.
I have found the following link ( ) 
which says:

"post mode is trickier. Assuming the request is an HTTP request, it is 
of course possible to add / modify X-Forwarded-For before entering post 
mode, but it won't be possible to modify subsequent requests on the same 
connection. This can be mitigated by also adding Connection: close to 
the request."

There is also a piece of VCL code:
if (bereq.http.x-forwarded-for) {
      set bereq.http.X-forwarded-for =
      bereq.http.X-forwarded-for ", "
      regsub(client.ip, ":.*", "");
      } else {
      set bereq.http.X-forwarded-for =
      regsub(client.ip, ":.*", "");

But I cannot seem to convince varnish.
Please advise.

More information about the varnish-misc mailing list