1

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!

0

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
  • That was a typo, sorry, I want it to be path_beg -i /voice like path_beg -i /text. – redsox2002 Sep 27 '16 at 13:11
  • Am I correct that all requests are going to the voice backend because of the host_connect line? You can also edit your question to fix the typo – Joe Sep 27 '16 at 14:44
  • Thank you, I edited the OP. So I have two backends, for voice and text. So the text portion is going to the text backend and voice and host_connect is going to voice backend. Host_connect is going to voice because I want when someone goes to website.com to go to the voice page, so that or /voice will go to the voice page. – redsox2002 Sep 27 '16 at 15:57
  • The problem is that if someone goes to website.com/text you will have host_connect acl set (because hdr(host) doesn't care what the URL is) and path_text acl set, but it will go to the voice backend because it matches the host_connect acl. It would be better to remove the host_connect acl (and it's associated use_backend line) and add a default_backend line for anything that doesn't match the path_voice and path_text acls. You could also remove the path_voice acl and only have the path_text acl and then change your last three lines to use_backend voice unless path_text – Joe Sep 28 '16 at 14:55
  • Do you mean something like this? acl path_text path_beg -i /text use_backend voiceqa unless path_text default_backend voiceqa Also what happens with the redirection? – redsox2002 Sep 29 '16 at 14:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.