Forum Discussion

Jacob_Kinkade_3's avatar
Jacob_Kinkade_3
Icon for Nimbostratus rankNimbostratus
Jul 17, 2017

Need help with irule

Looking for feedback on irule for redirect. I am a network engineer who had our loadbalancers dumped in my lap and a request for an irule to be placed.

Not familiar at all with how to do this but I hope I am on the right track. "; those requests need to only go to one server "; I want the rest of the traffic that normally is served by the server to be balanced across the pool as normal.

From all my research it should look like this? And all I need to do is put it under the irules section under local traffic correct?

    when HTTP_REQUEST {
if
{ [HTTP::uri] equals "https://server-fiver.domain.com/index" }
{ HTTP::redirect "https://srv-one-games001-test/location/" }
}

Thank you ahead of time!

4 Replies

  • P_K's avatar
    P_K
    Icon for Altostratus rankAltostratus

    Hope this work..

    1. Create this irule under Local traffic --> iRules
    2. Apply it to your virtual server under Local Traffic --> Virtual servers and once you are in the virtual server properties page, click Resources tab from top, add the irule you created in iRule section.

    when HTTP_REQUEST {

    if { string tolower [HTTP::uri] equals "/index" } {

    HTTP::uri "/location"

    node Insert_IPaddress_Of_srv-one-games001-test Port_of_srv-one-games001-test

    Example: node 10.10.10.10 8080

    }

    else {

    Default_pool //Change this to your default pool name

    }

    }
  • When you say you want it to only go to one server;

     

    a. Not go through F5, F5 only redirects the client to the actual server

     

    b. Still go through F5, but F5 only sends the traffic to a specific server

     

    I know that you've written it as scenario a, but I've talked with too many who actually meant b. I can also see that PK and Andrew are solving the question two different ways; b and a respectively.

     

  • I have a pool of servers. The developers hosted something on one of these servers and asked that a rule be created that sends requests for those assets straight to that directory, with all other requests for other assets to be balanced across the pool as normal. So situation b. Sorry for not being as clear when I wrote it, it was a long night.

     

  • I haven't tested this iRule but given the conditions I'd go for

    when HTTP_REQUEST {
     redirects the client to the correct catalogue
    if { ([string tolower [HTTP::host]] equals "server-fiver.domain.com") && ([string tolower [HTTP::uri]] == "/index") }{
        HTTP::redirect https://[HTTP::host]/location/
        }
     send the client to the server when requesting this catalogue
    if { [string tolower [HTTP::uri]] starts_with "/location/" } {
        pool my_pool member srv-one-games001-test 443
        }
    }
    

    If there's only one domain for the VIP it is not necessary to have both conditions in the first if statement.