Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HAProxy : Replace rsprep directive by http-response replace-header

Tags:

haproxy

I inherited a haproxy server that was running the version 1.8. Upgraded it to version 2.1. Haproxy wouldn't restart. Found in the log that the issue was with this line in the configuration file:

rsprep ^Set-Cookie:\ (.*) Set-Cookie:\ \1;\ Secure

The error was

The 'rsprep' directive is not supported anymore since HAProxy 2.1. Use 'http-response replace-header' instead

Removed rsprep and it worked. But I am now curious to know what impact it may have. How do I replace the above configuration using http-response replace-header?

like image 202
Allen King Avatar asked Sep 10 '25 22:09

Allen King


1 Answers

It looks like it's adding the word Secure to the Cookie header value. It's doing a regex, capturing everything as group 1, then referencing group 1 and adding Secure to the end. Per docs.

Using replace header:

http-response replace-header Set-Cookie (.*) \1;\ Secure

There are more examples in the docs here

like image 90
jmoney Avatar answered Sep 13 '25 20:09

jmoney