haproxy http-response 替换

haproxy http-response replace

我正在尝试替换响应 header "abc,def,ghi,jkl" 中的这部分字符串。请注意此值不是静态的。

  My-Customer-Header: My-Test:abc,def,ghi,jkl:12345 

使用这个正则表达式,我可以在冒号之间抓取字符串。即 "My-Test" & "12345" https://regex101.com/r/Ebkzjb/1

这是我要替换的值..

  My-Test:XYZ:12345

这是我的 haproxy 配置行..

  http-response replace-value  My-Customer-Header (.*)((?<=:)(.*)(?=:))(.*) XYZ

语法上,haproxy 配置正在加载,但我可能没有正确的正则表达式。能否请您帮助 haproxy 配置以替换值。

这对我有用

 http-response replace-header My-Customer-Header (.*)((?<=:)(.*)(?=:))(.*) XYZ