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 redirect to http://hostname/public
possible?
Regards
Charlie
when CLIENT_ACCEPTED {
if { ([HTTP::host] equals "hostname.com") }
if {[HTTP::uri] equals "mcx" }
if { [IP::addr [IP::client_addr]/8 equals 10.0.0.0] }
if { [IP::addr [IP::client_addr]/16 equals 192.168.0.0] } {
HTTP::redirect "http://hostname.com/public"}
} elseif {
drop
}
}
2 Replies
- hoolio
Cirrostratus
That'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".class private_net { network 10.0.0.0/8 network 172.16.0.0/12 network 192.168.0.0/16 }
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" } } } }
- Charlie_2_10323
Nimbostratus
Thanks Aron,
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