Forum Discussion
IRule Customization
We have a requirement to create irlue with the following logic
We have One VS and Two POOL (Pool x and Pool Y)and differentiate the traffic based on requested hostname by the following irule
==================
when HTTP_REQUEST { if {([HTTP::host] contains "auction.com")} {pool Auction-Pool}
if {([HTTP::host] contains "test.com") {pool test-Pool}
}
====================
For certain hostname (auction.com) we need to do the following
From internet: All users has to access : https://auction.com
From internet: All users should not have to access to: https://auction.com/test/admin
From intranet : Only following subnet below should have access to : https://auction.com/test/admin
Network1 Range: 10.10.10.X/24
Network2 Range: 20.20.20.X/24
- Samir_Jha_52506
Noctilucent
Do you want to club both condition in iRule?
- Andy_McGrath
Cumulonimbus
I think the following should work for you:
when HTTP_REQUEST { set selectedPool [LB::server pool] set lowerHost [string tolower [HTTP::host]] set lowerPath [string tolower [HTTP::path]] if {$lowerHost ends_with "auction.com"} { set clientIP [getfield [IP::client_addr] "%" 1] if {($lowerPath starts_with "/test/admin") && !(([IP::addr $clientIP equals 10.10.10.0/24]) || ([IP::addr $clientIP equals 20.20.20.0/24]))} { reject } set selectedPool Auction-Pool } elseif {$lowerHost ends_with "test.com"} { set selectedPool test-Pool } pool $selectedPool }
I have also published as a snippet here Snippet: irule-customization-63561
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com