Forum Discussion

Br3nt's avatar
Br3nt
Icon for Nimbostratus rankNimbostratus
Aug 13, 2020

iRule to allow specific URL but block the root domain

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.

  • Br3nt's avatar
    Br3nt
    Icon for Nimbostratus rankNimbostratus

    amazing no one wants to help...I'll give it a few more hours and then delete the question.

  • 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"