Hi all

Recently I needed to substitute http headers in requests such as the following:

Referer: https://a-b-c.example.com/x-caliber
Referer: https://a.b.c.example.com/x-caliber

Basically any hyphen in the subdomain part of example.com needed to be replaced 
by dots, but any other hyphens should not be replaced. I tried doing it with 
regsub() but the limitation on the accepted characters (no parenthesis or 
square brackets) limits the possible regular expressions that can be used. Also 
“http-request replace-header” is limited because it does not handle multiple 
matches – if there is more than one match there is no way of back-referencing 
to all matches (so varying number of matches cannot be handled). What I needed 
was a cross between replace-header and regsub. So I am suggesting the 
substitute-header and substitute value actions for http requests and responses.

I have a reference implementation for this on my github branch here: 
https://github.com/darcoli/haproxy/tree/substitute-header-value. I am also 
attaching a patch with my changes with this email.
I have done some testing and am confident the basic functionality works. But 
please review and I will be happy to handle any suggestions or fixes that you 
may have.

Best regards
Darren Demicoli


Darren Demicoli

Devops Engineer


(+356) 796 853 46 | Skype: darren.demicoli


MT: Spinola Park, 7th Floor, Triq Mikiel Ang Borg, SPK1000. St. Julians, Malta
PL: ul. Sobieskiego 2, 40-082 Katowice, Poland




XCaliber is an ISO27001 certified company for information security management.

This message (including any attachments) may contain confidential, proprietary, 
privileged and/or private information. The information is intended to be for 
the use of the individual or entity designated above. If you are not the 
intended recipient of this message, please notify the sender immediately, and 
delete the message and any attachments. Any disclosure, reproduction, 
distribution or other use of this message or any attachments by an individual 
or entity other than the intended recipient is prohibited.

Attachment: substitute-header-values.patch
Description: substitute-header-values.patch

Reply via email to