URL Redirection in Haproxy.cfg

haproxy

I am trying to redirect a URL in my haproxy.cfg file and not sure where to start. What my goal is whenever I go to https://website/text it gets redirected to https://website/#/text/conversation and same thing with voice. How exactly can I do this? I am using HAProxy version 1.5.14. Below is what I have (tried), but it's not working as I want it to.

frontend HTTPS_IN
acl host_connect hdr(host) -i website.com
acl path_voice path_beg -i /voice
redirect location https://website/#/voice/voicemail if path_voice
acl path_text path_beg -i /text
redirect location https://website/#/text/conversation if path_text
use_backend voice if path_voice
use backend voice if host_connect
use_backend text if path_text

Am I on the right path at all? If not, can you guys please help me out?

Thanks!

Best Answer

It looks like you set the host_connect acl if it connects to website.com. Nothing changes this later so it will always match use backend voice if host_connect So I expect you are always going to end up at the voice backend.

Try doing this instead:

frontend HTTPS_IN
acl path_voice path_beg -i /voice
redirect location https://website/#/voice/voicemail if path_voice
acl path_text path_beg -i /text
redirect location https://website/#/text/conversation if path_text
use_backend voice unless path_text