12-Aug-2020 20:17
We have a a mobile app that uses the URL /wfc. We need to block non-mobile access to the site by blocking the root domain from internet access.
This iRule will be assigned to the VS that processes this web traffic.
As a novice, I have used examples here to draft an iRule. I need help with the format, syntax and arguments. I know I'm missing a few brackets 🙂
when HTTP_REQUEST {
log local0. "Requested connection [HTTP::host][HTTP::path], converted [string tolower [HTTP::host][HTTP::path]]"
if {[string tolower "[HTTP::host][HTTP::path]"] contains "/wfc"} {
log local0. "Accepted Connection [HTTP::host][HTTP::path], converted [string tolower [HTTP::host][HTTP::path]]"
forward
} else {[string tolower "[HTTP::host][HTTP::path]"] equals "subdomain.domain.org"} {
log local0. "Rejected Connection [HTTP::host][HTTP::path], converted [string tolower [HTTP::host][HTTP::path]]"
HTTP::respond 403 content{request Forbidden}
}
}
Thank you in advance for your advice and mentorship.
16-Aug-2020 21:38
its best to give people the benefit of the doubt.
when HTTP_REQUEST {
if {[string tolower [HTTP::host][HTTP::path]] contains "/wfc"} {
<whatever pool or node you want to send traffic to>
} else {
HTTP::respond 403
}
}
Based on what you're describing, this should work. The second line of your irule has the "contains" modifier. This will find "/wfc" no matter where it's in the uri. If that's not your intention, you can also use "starts_with" or "ends_with" instead of "contains"