Hello,

How do I use "ltrim" 
(https://www.haproxy.com/documentation/haproxy-configuration-manual/latest/#7.3.1-ltrim)
 ?

Trying to do a redirect short.com/123456 to example.com/id123456
http-request redirect location https://example.com/id%[path,ltrim(/)] if { 
req.hdr(host) -i short.com && path_reg -i ^/\d+$ }

But I am getting a error:
error detected in proxy 'example.com_443' while parsing 'http-request redirect' 
rule : expects 'code', 'prefix', 'location', 'scheme', 'set-cookie',
'clear-cookie', 'drop-query', 'ignore-empty' or 'append-slash' (was 
'ltrim(/)]').

I could not find any public example of this being used. Github, Stackoverflow, 
the mailing list, discourse.haproxy.org did not provide any help.

I have found an alternative using regex (probably more CPU intensive?):
http-request redirect location https://example.com/id%[path,regsub(/,,g)] if { 
req.hdr(host) -i short.com && path_reg -i ^/\d+$ }


-- 

 
Tom Braarup          
Senior Linux Administrator
IT Infrastruktur Platform - Digital Udvikling og Teknologi
________________________________


 


Reply via email to