Make HAProxy strip spaces from a request header
There is some shared code out in the wild that browser extensions are using to make requests, which might cause problems if you parse the Referer header in your website.
The issue is with the following request header, which you might see in your logs as
Referer: http:// www.example.com
That space between the scheme and host name causes the problem.
Strip Spaces from request headers
The following rule goes in your HAProxy backend, and replaces the Referer header with the same values stripped of spaces.
http-request set-header Referer %[req.hdr(Referer),regsub(' ','',g)]
A similar rule could be used for other request headers if necessary.