Forum Discussion
Shay_Ben-David1
Nimbostratus
Mar 25, 2008block access to domain
is there a way to filter access only to the domain root like www.mysite.com, and allow everything else, in order to allow users bookmarks and uri with specific url+uri
my irule is :
when HTTP_REQUEST {
if { ( [string tolower [HTTP::header Host]] equals "www.mysite.com" ) }{
log "client: [IP::client_addr], requested [HTTP::host][HTTP::uri]"
discard
}
}
i want to add the http::uri
thanks
14 Replies
- The_Bhattman
Nimbostratus
Check this outwhen HTTP_REQUEST { if { NOT ( [string tolower [HTTP::host]] equals "www.mysite.com" ) } { log local0. "client: [IP::client_addr], requested [HTTP::host][HTTP::uri]" discard } }
The logic here is anything NOT matching www.mysite.com is discarded
Hope this helps
/CB - Shay_Ben-David1
Nimbostratus
does your change will allow www.mysite.com/images/abc.jpg or some other uri ?
the meaning for this irule is to disallow the www.mysite.com/ and allow all other requests with specific uri
thanks - Nicolas_Menant
Employee
yes it will allow everything starting with www.mysite.com
because here we talk about the host and not the URI.
when you do www.mysite.com, www.mysite.com/abc/test.html
they have the same host which is www.mysite.com
If you need to allow some URI you'll need to make some URI checking with the command [HTTP::uri] - The_Bhattman
Nimbostratus
The rule is to allow ONLY host "www.mysite.com" in with any combination of URI.
The NOT in the statement is simply to say the following:
"If hostheader is not www.mysite.com then block the request"
/CB - Shay_Ben-David1
Nimbostratus
lets say i would like to redirect everything that goes to www.mysite.com, and different uri will not be redirected like: www.mysite.com/images/abc.jpg or any other request beside the www.mysite.com, do you have idea how to perform this ?
thanks - Nicolas_Menant
Employee
when HTTP_REQUEST {
if { [string tolower [HTTP::host] equals "www.mysite.com" } {
if { NOT ([HTTP::uri] contains "images")} {
HTTP::redirect "www.newsite.com"
}
}
}
Here we redirect all users requesting www.mysite.com but not user where the uri contains images. - Nicolas_Menant
Employee
when HTTP_REQUEST {
if { [string tolower [HTTP::host] equals "www.mysite.com" } {
switch -glob [HTTP::uri] {
"/images*" -
"/admin*" -
default {
HTTP::redirect "www.newsite.com"
}
}
} - The_Bhattman
Nimbostratus
Here is another adding a discard into nmenant's codewhen HTTP_REQUEST { if { [string tolower [HTTP::host] equals "www.mysite.com" } { switch -glob [HTTP::uri] { "/images*" - "/admin*" - default { HTTP::redirect "www.newsite.com" } } else { discard } } - Shay_Ben-David1
Nimbostratus
im getting error on line1 and 2 ? - Nicolas_Menant
Employee
when HTTP_REQUEST { if { [string tolower [HTTP::host]] equals "www.mysite.com" } { switch -glob [HTTP::uri] { "/images*" - "/admin*" - default { HTTP::redirect "www.newsite.com" } } else { discard } }
1 ] was missing after the [HTTP::host]
If you can copy the error messages it may help too but should be ok now
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects
