Hi folks,

I have a need to capture the exact headers sent by a client. The problem is I also use options forwardfor and http-server-close, so the headers sent to my backend are altered by HAProxy.

My plan is to copy any affected headers under new names, using a special prefix. This way my backend application has a way to differentiate between modified headers and original headers. HAProxy doesn't seem to have a command for copying headers. There is only reqadd for adding and reqrep for replacing. However, I can fake a copy by injecting a newline in the middle of a replacement value:

  reqirep ^(Connection:)(.*) Connection:\2\nOrig-\1\2

If the client provides:

  Connection: Keep-Alive

Then the above rule (along with http-server-close) will cause HAproxy to send the request with:

  Connection: Keep-Alive
  Orig-Connection: Keep-Alive
  Connection: close

My backend application can then be configured to capture the Connection header only if it is prefixed.

This seems to work, but I am posting to the mailing list first just to confirm if this isn't an abuse of reqirep.

Thanks,
Justin

Reply via email to