Forum Discussion
URI access for all for 4 URIs and rest of the URIs based on IP whitelisting
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] equals "abc.com" } {
Check if requested URI matches for access to all
switch -glob [HTTP::uri] {
"/6110.aspx" -
"/9018.aspx" -
"/9044.aspx" -
"/3001.aspx" {
pool ABC_TEST_V
}
}
} elseif { [string tolower [HTTP::host]] equals "abc.com" } {
if { [class match [IP::client_addr] equals ABC_all] } {
Process the traffic for all IPs for URL abc.com pool ABC_TEST_V
} else {
Drop the connection
drop
}
}
}
when HTTP_RESPONSE {
foreach mycookie [HTTP::cookie names] {
HTTP::cookie secure $mycookie enable
}
}
Are your 'if' and 'elseif' trying to match on the same text? The hostname is in small case, yes the hostname is same for if and elseif statement. I am match 4 URIs if they match I send to the pool else I have to check the IP whitelisted->yes->then goto to pool
- dragonflymrJun 08, 2017
Cirrostratus
OK, but when if condition is matched then elseif will never be triggered.
elseif should just contain different condition that if.
To have anything performed for other URI than specified in your switch you should place your additional conditions in switch default declaration like:
switch xyz { a - b {format 1} a* {format 2} default {format 3} }Piotr
- rajeshgoudJul 13, 2017
Altostratus
following logic worked
when HTTP_REQUEST { switch -glob [ string tolower [HTTP::host]] { "abc.com" { switch -glob [HTTP::uri] { "/6110.aspx" - "/9018.aspx" - "/9044.aspx" - "/3001.aspx" { pool abc_V } "/5005.aspx" { if { [class match [IP::client_addr] equals abc_5005] } { pool abc_test_V } } default { if { [class match [IP::client_addr] equals abc_internet] } { Process the traffic for all allowed IPs for URL abc.com pool abc_test_V } else { Send HTTP reject message HTTP::respond 403 content { Access Restricted!Please make sure you are on CA Network to access this application } } } } } } }
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
