Forum Discussion

socar65's avatar
socar65
Icon for Nimbostratus rankNimbostratus
Apr 04, 2018

Redirect to another url and pool

Hi All,

 

Got a requirement from my user who is adding a new application, but the old app is still tied to some other services, so they don't want to get rid of that app, rather redirect to that application but pull up their new servers pool. I have tried to get this going , the redirect to the 302 works, but it keeps pulling up the old pool. Here is an example.

 

if { ($requestURI starts-with "/blue/ui/")} { HTTP::respond 302 location ";

 

TCP::close } elseif {($requestURI equals "/")} { pool ext_newpool ] }

 

As I said, the redirect to 302 location works fine, but I can't seem to get the new pool to load during that redirect, the 302 location pool loads.

 

Thanks

 

Jess

 

  • I don’t understand the elseif condition!

     

    What behavior is expected if uri is not / and doesn’t start with /blue/ui/

     

  • I had set this up as two irule, the first irule is for the redirect to new URL alone and the second irule is to check the new URL header/ URI string match and send it to the new pool.

     

    • socar65's avatar
      socar65
      Icon for Nimbostratus rankNimbostratus

      Rajesh,

       

      Thanks -- can you send me an example of that irule.

       

    • Rajesh_261121's avatar
      Rajesh_261121
      Icon for Nimbostratus rankNimbostratus

      Here is the first one

       

      when HTTP_REQUEST { if { [HTTP::host] eq "header.org" && [HTTP::uri] eq "/uri" } { HTTP::redirect "http://header2.org/newuri/"; } } Second one:

       

      when HTTP_REQUEST { if { ([HTTP::host] eq "header2.org") && ( [HTTP::path] starts_with "/newuri") } { pool new-pool } }

       

    • Stanislas_Piro2's avatar
      Stanislas_Piro2
      Icon for Cumulonimbus rankCumulonimbus

      @Rajesh : This is the worst advice you can do.

       

      when working with multiple irules, all irules are evaluated.

       

      so even if the first irule matches, the second can be evaluated and may cause TCL error and TCP reset.

       

      if irule 1 make a redirect for URI /uri and irule 2 add a HTTP header for all URI, there is a conflict which cause TCP reset (because HTTP insert command is not allowed if there is a redirect before).

       

  • Hello,

     

    For this needs you can use "LTM Policies", the configuration is graphical is easier to manage. you can break down your need into two rules in your policy.

     

    first rule: if host eq header.org" && uri eq "/uri --> Redirect

     

    second rule: if host eq header2.org" && uri eq "/newuri --> new pool

     

    just one thing, do not forget to activate the oneconnect (whatever solution you use, irule or policy, to detach the session when you change pools ).

     

    Regards

     

  • Hi Oscar, I'm really curious if you got this working and how. I'm dealing with the same issue of needing to route to two different pools based on URI. I have tried the solutions mentioned here and in a few other posts and no matter what I do, it routes to the default pool only. If I remove the default (set it to none) and route with an

    if (x) { pool 1 } else { pool 2 }
    I get connection resets.