cancel
Showing results for 
Search instead for 
Did you mean: 

iRule to redirect header to a specific node

mahanth
Altostratus
Altostratus

Hello we created an iRule to redirect header with a specific value to a particular node. But, we were not able to specify the node name and had to specify the node IP address. Is there a way to specify node/member name instead of the IP?

iRule:

when HTTP_REQUEST {

  if { [HTTP::header exists test]} {

    set node [HTTP::header value test]

    node $node 80

  }

}

2 REPLIES 2

Hi mahanth,

 

node command only supports IP address.

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

 

You can create pools having one member for each node.

pool <pool_name>

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

mahanth
Altostratus
Altostratus

Hello,

 

Can I get the node IP from the pool name and eventually pass them as parameters.

 

Something like: (but the problem is, it doesn't take tmsh commands)

 

when HTTP_REQUEST {

    if { [HTTP::header exists test]} {

        set POOLNAME [LB::server pool]

        set NODENAME [HTTP::header value test]

        for POOLMEMBER in `tmsh list ltm pool $POOLNAME | grep : | sort | awk '{print $1}'`; do

            if { [string tolower $POOLMEMBER] equals [string tolower $NODENAME] } {

                pool $POOLNAME member ($(tmsh list ltm node $POOLMEMBER_NAME | grep "address")) 80

                break

            }

        done

    }

}