Forum Discussion
Charlie_2_10323
Nimbostratus
Jun 22, 2009Hostname uri and source-ip based access
Hi
I would like have a rule which I can
Check hostname
Check uri
And Check source network (should be private Network 10../8 192.168./16 )
If all matches than redire...
hoolio
Cirrostratus
Jun 22, 2009That's close in concept. If you want to check the hostname and URI, you'll need to wait until the HTTP_REQUEST event to check as this is when the HTTP headers have been parsed. The URI will always start with a forward slash, so you might want to see if the URI equals "/mcx".
Also, there is a default datagroup named private_net which you can reference with matchclass:
class private_net {
network 10.0.0.0/8
network 172.16.0.0/12
network 192.168.0.0/16
}
So you could use something like this:
when HTTP_REQUEST {
Check if client IP is a private network
if {[matchclass [IP::client_addr] equals $::private_net]}{
Check if requested host is hostname.com
if {[string tolower [HTTP::host]] eq "hostname.com"}{
Check if URI starts with "/mcx"
if {[string tolower [HTTP::uri]] starts_with "/mcx"}{
HTTP::redirect "http://hostname.com/public"
}
}
}
}
Aaron
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
