Mass redirect using Haproxy map file

After some migration between applications versions you need to keep backward compatibility. Here example of easy way how to redirect lot of links to new location for Haproxy.  (example for Nginx)


Haproxy config example
map_hash_bucket_size 256;
 frontend http
  bind *:80
  bind *:443 ssl crt /etc/haproxy/all-domain-com.pem
...
  http-request redirect location %[capture.req.uri,map(/etc/haproxy/redirect.map)] code 301 if { capture.req.uri,map(/etc/haproxy/redirect.map) -m found and hdr(host) -i domain.com }
...
  redirect scheme https code 301 if !{ ssl_fc }

Redirect MAP
map_hash_bucket_size 256;
# cat /etc/haproxy/redirect.map | head -5
/free-slot-online    https://domain.com/all-games
/free-auto-spin-slot    https://domain.com/auto-spin
/free-auto-play-slot    https://domain.com/auto-play
/free-wild-slot-online    https://domain.com/wild-symbols
/5-reel-slot-online    https://domain.com/5-reels

Comments

Popular posts from this blog

FreeRadius and Google Workspace LDAP

pssh (parallel-ssh) problems on Debian 10 with Python 3.7