Rspirep - HAProxy Upgrade - Help Needed!

Hi All,

I have just upgraded from 1.5.2 to 2.4.14 , and as you may all know rspirep is no longer supported, and I need to use http-response replace-header instead, but am having issues getting it working with backslashes followed by numbers, which by the documentation, seems to be supported in 2.4

https://cbonte.github.io/haproxy-dconv/2.4/configuration.html#http-request%20replace-header

This is what was previously configured:

rspirep ^(Location:)\ http://([^/])/(.)$ \1\ https://\2/\3

I tried the following, but none worked unfortunately:

Option 1: http-response replace-header Location (http://[^/])/(.) \1 https://\2 if { hdr(Location) -m found }

[ALERT] (5279) : parsing [/etc/haproxy/haproxy.cfg:66] : error detected in proxy ‘X’ while parsing ‘http-request replace-header’ rule : regex ‘Location: https://\1/\2’ is invalid (error=reference to non-existent subpattern, erroffset=23).

Option 2:

http-request replace-header ^Location:\ http://([^/])/(.)$ Location:\ https://\1/\2 if { hdr(Location) -m found }

Error 2:

[ALERT] (5279) : parsing [/etc/haproxy/haproxy.cfg:66] : error detected in proxy ‘X’ while parsing ‘http-request replace-header’ rule : regex ‘Location: https://\1/\2’ is invalid (error=reference to non-existent subpattern, erroffset=23).

I would highly appreciate any help anyone can give.

Thanks,
Ash

http-response replace-header Location ^http://(.*) https://\1

You can find more example of this syntax in the docs of the http-request equivalent:

http://docs.haproxy.org/2.4/configuration.html#4.2-http-request%20replace-header