node select iRule
Hi,
I have created an iRule that that is supposed to send traffic to a specific node depending on input from the URI. The iRule looks like this:
when HTTP_REQUEST { set node_ip [getfield [HTTP::uri] "/" 4] if { $node_ip >= 160 and $node_ip <= 253 } { HTTP::uri [string map [list $node_ip ""] [HTTP::uri]] node "10.1.1.$node_ip" 80 } else { pool mediaroot-pool } }
The idé is that if I use the url http://example.com/foo/bar/mediaroot/image1.jpg I will be sent to the "default" pool mediaroot-pool. But if I go to the url http://example.com/foo/bar/170/mediaroot/image1.jpg I will be sent to the node 10.1.1.170 and the URI will be changed to /foo/bar/mediaroot/image1.jpg with a rewrite.
I have created nodes between .160 and .253.
The part of the iRule that is not working is this: if { $node_ip >= 160 and $node_ip <= 253 }
If I go to the URL http://example.com/foo/bar/170/mediaroot/image1.jpg its sent to the correct node but with the URL http://example.com/foo/bar/mediaroot/image1.jpg the if statement thinks that mediaroot (getfield value 4) is correct.
Is the if statement that checks if the $node_ip is between 160-253 wrong?
Regards Andréas