Forum Discussion

TQ72_165667's avatar
TQ72_165667
Icon for Nimbostratus rankNimbostratus
Oct 30, 2017

Common Host redirect with different URIs

Hi,

What I thought was quite a simple issue, but am struggling to resolve.

I would like to redirect to a pool, lets say POOL_1 with one node (at the moment) http://1.2.3.4:8080/uri_x and then secondly to redirect to another pool, POOL_2 with another single server but same uri - http://4.3.2.1:8080/uri_x

Whilst apparently initially working, opening 2 tabs causes the first tab with site 1 to change to site 2 if site 2 is opened on tab 2. Also, a refresh of either page after some time brings about a 404 - but am guessing that this is because of nothing accounting for

I have tried the following initially but have been round in circles with switch, string map, and various persistence settings - all without any progress. We rewrite 'all' in the http profile because of the application.

Any help really appreciated. Thank you.

if {([HTTP::host] equals "site1") && ([HTTP::uri] starts_with "/uri_1")} {
        pool POOL_1 
        HTTP::redirect "/uri_x"
    }
    elseif {([HTTP::host] equals "site1") && ([HTTP::uri] starts_with "/uri_2")} {
        pool POOL_2 
        HTTP::redirect "/uri_x"
    }

2 Replies

  • The reason your script is not working is because of the 'HTTP::redirect "/uri_x"' command. The redirect command is only sending a redirect to the client and forcing a reconnection back to the virtual server. The redirect command is not actually doing anything to the backend servers (pool members).

     

    Instead of the redirect, edit and change the actual uri string, before the "pool [...]" command. Something like this:

     

    HTTP::uri = "/uri_x"

     

    if (criteria_A) { HTTP::uri = "/uri_x" pool pool_A } elseif (criteria_B) { HTTP::uri = "/uri_x" pool pool_B }

     

    DON'T FORGET TO ASSIGN A DEFAULT POOL FOR A CATCH ALL SITUATION. That should do the trick.