Forum Discussion

Joseph_Johnson_'s avatar
Joseph_Johnson_
Icon for Nimbostratus rankNimbostratus
Sep 11, 2017

Redirect to pool based on URI

Hi,

 

I am trying to create a redirect either using irules or policies but neither are working correctly. The scenario is, a user has an application that has 3 different apps listening on 3 different ports. They want to be able to type first.second.com and go to the default app, first.second.com/two and go to a different app and first.second.com/three and go to another app. I have done this but with using ports in the host name and switching to a different pool based on the port, but they dont want any ports in the URL as this will be external facing. I tried creating some policies based on the URI but it broke because after you land on the app, it redirects you to the login page which changes the URI to first.second.com/login which breaks the logic of the policy. Is there any policy or iRule that can be written to get around this issue. Any help would be appreciated.

 

Thanks

 

  • So the expected behaviour is:

     

    • URI starts with "/three" -> app3
    • URI starts with "/two" -> app2
    • all other URIs -> app1

    If so, then you can do this with a single virtual (ip address/port) three pools and an irule.

     

    Take a look at the ProxyPass irule that does what you are looking to do (with dynamic pool selection and content examination).

     

    You could base a simpler irule on Proxypass: The irule chooses the correct pool based on the request URI.

     

    In the response, it searches for links and inserts a leader into returned URIs in the html where required (i.e, if the link URI starts with /, and pool 2 was selected for the request, insert "/two").

     

    If the applications cannot be split up as described above, then things get more complex.