Forum Discussion

Margvin's avatar
Margvin
Icon for Cirrus rankCirrus
May 13, 2023

Irules and policy,direct pool member based On Http uri

Spoiler
Spoiler
hi all I have a question about how to configure irules and policies. If an http request has a specific http uri, for example / event, then it will be thrown to, for example, to pool member A and will call an ifile, for example, F5 image, I want to know an example of irules and its policies. Thank you for your help
  • Margvin I am not seeing any content if you could please correct the issue then at that point we should be able to assist you further.

  • LTM basic configuration will link a certain number of Node <IP:port> sockets to your LTM Pool, and then link the LTM pool to the Virtual Server.

    Without iRules and/or policies, F5 will forward every client request to the node that was selected using the specified LB method.

    iRules and policies can modify this behavior. The first thing you should dunderstand is that it's event-driven, so your first statement in irule code should specify when you want to change the behavior. 

    In your example, when the first HTTP packet is seen on F5 whe HTTP_REQUEST even will fire. (There's several more that will fire before that). With an HTTP profile, you can script something that retrieves informations on this request and possibly rewrite it, or use it to change LB behavior:

    when HTTP_REQUEST {
      set uri [HTTP::uri]
      if {$uri starts_with "/event"}{
        # do something
      }
    }

     

    Different events can fire when LB selects your node, so you can change the behavior on that event as well.
    When F5 receives the http response, once again another event will fire and more decisions can be made ..

    All of iRule commands, events, etc. are documented online 

    https://clouddocs.f5.com/api/irules/Commands.html