Path Map does not match with non-English path

I have a lot of paths (40k) to redirects.
So, that I would like to put them in the map file (that is, redirect-list file) to manage it.

But, those paths contain non-English paths too (which is required to be human readable and editable later on, it means that I can’t put url encode path there which will be matched fine).

Right now my current config looks like this:

frontend ssl_443
 # bind *:443 ssl crt /etc/ssl/private/test.pem
 bind *:443 ssl ssl crt-list /etc/haproxy/cert.crt-list
 mode http
 http-request set-header X-Forwarded-For %[src]
 http-request add-header X-Forwarded-Proto https
 option http-server-close

# acl thai path_beg -i /ทดสอบ <-- this matches fine.
# http-request set-path /my-new-path

 http-request redirect location %[path,map(/etc/haproxy/redirect-list)]?%[query] code 301 if { path,map(/etc/haproxy/redirect-list) -m found } { query -m found }
 http-request redirect location %[path,map(/etc/haproxy/redirect-list)] code 301 if { path,map(/etc/haproxy/redirect-list) -m found } ! { query -m found }

 default_backend ssl_443

backend ssl_443
 mode http
 balance leastconn
 server web1 10.0.0.1:80 check
~# cat /etc/haproxy/redirect-list
/google https://www.google.com
/555 /hahaha
/ทดสอบ /my-new-path
/ภาษาไทย /new-page
/my-old-path /my-new-path

When accessing
/ทดสอบ, it does not match

But, accessing
/my-old-path, it’s matched and redirected to /my-new-path

So, I wonder, is there any way to make the following if block:

if { path,map(/etc/haproxy/redirect-list) -m found } ! { query -m found }

matched with non-English path ?

So what you need is an interface that abstracts this problem away, so you can edit your “source” file or database with non english paths, and periodically and triggered on changes write the change to the actual url escaped map file.

There are non-ASCII paths and haproxy cannot solve this problem for you.

1 Like

@lukastribus I see, I also have been thinking this solution.
Because acl thai path_beg -i /ทดสอบ works fine with non-Ascii path.

So, just would like to make sure if I’m missing any functions or something on map file before implementing this abstraction.

But, as you mentioned, adding new layer of interface for user to interact with would probably be the only way to solve this.

Also, just for anyone who might be interested.
Here is my quick implementation haproxy-redirect-map/data.csv at main · zdk/haproxy-redirect-map · GitHub I use csv as interface for user to abstract away from actual map file and used it build url encoded for the map file included in haproxy.cfg.