Forum Discussion
iRule to block HTTPS uri
I have a request from a customer to block a specific HTTPS uri. When the URI is hit, the connection is rejected and return a http 404 error.
URI: https://aaaa.com/bbb/ccc.xml
I just wanted to confirm if the following will work:
when HTTP_REQUEST { if { [HTTP::uri] starts_with "https://aaaa.com/bbb/ccc.xml" } {
HTTP::respond 404
}
}
3 Replies
- Kevin_Stewart
Employee
The [HTTP::host] command will return the Host header portion of the URL (ex. aaaa.com), while the [HTTP::uri] command will return the URI portion of the URL (ex. /bbb/ccc/xml). If you just care about the URI, then the following should work:
when HTTP_REQUEST { if { [string tolower [HTTP::uri]] starts_with "/bbb/ccc.xml" } { HTTP::respond 404 "Not Found" "Connection" "close" } } - FFX2014_23725
Nimbostratus
For this situation I do care about the host header since the link has both HTTP and HTTPS instance. We only want to block the HTTPS and still allow HTTP.
Is this correct?
when HTTP_REQUEST { if { [string tolower [HTTP::host]] starts_with "https://aaaa.com/bbb/ccc.xml" } { HTTP::respond 404 "Not Found" "Connection" "close" } }
- Kevin_Stewart
Employee
You're presumably going to have this iRule applied to an HTTP or HTTPS VIP, so the http:// or https:// in the request will be respective to the applied VIP. You can evaluate the protocol scheme, but you shouldn't have to. Further, the HTTP_REQUEST event is going to be triggered on an HTTP request to the VIP, which the user is going to generally request by name (or IP). If you filter on the name in the iRule, then the user can bypass the condition by using the IP address to access the VIP.
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