Forum Discussion
player_72606
Nimbostratus
Jul 19, 2009uri by source ip
Hi all,
newbie here :-)
i need help writing iRule to filter uri by source ip :
for uri /web/admin=1 - source ip 1.1.1.1
for uri /web/admin=0 - all others
hen HTTP_REQUEST {
if { [URI::decode [string tolower [HTTP::uri]]] contains "web/admin=1"
}
{
if {[matchclass [IP::remote_addr] equals $::management_ip]
}
{
log local0.info "Allowed client to uri: [IP::remote_addr] requesting: [HTTP::uri]"
}
else
redirect{ [URI::decode [string tolower [HTTP::uri]]] contains "web/admin=0"
{
log local0.info "not web manager: [IP::remote_addr] requesting: [HTTP::uri]"
}
}
what's wrong here?
- player_72606
Nimbostratus
missing close brace........ - player_72606
Nimbostratus
is this the right way to do this? - player_72606
Nimbostratus
the ip restrication should be based on the parameter in the uri : - hoolio
Cirrostratus
Hi,when HTTP_REQUEST { Check requested path if {[string tolower [URI::decode [HTTP::path]]] eq "/web/admin.aspx"}{ Check login parameter value if {[URI::query [HTTP::uri] "login"] eq "1"}{ Request to restricted resource. Check if client IP is not 1.1.1.1 if {not ([IP::addr [IP::client_addr] equals 1.1.1.1])}{ Take some action to prevent request? Rewrite login=1 to login=2 HTTP::uri [string map {login=1 login=2} [HTTP::uri]] Redirect client to rewritten URI? HTTP::redirect [string map {login=1 login=2} [HTTP::uri]] } } } }
- player_72606
Nimbostratus
only source ip 1.1.1.1 should be allowed to access =1 - hoolio
Cirrostratus
To discard a connection, you can use the discard command. I'm not sure I understand the exact logic you're trying to implement, but hopefully the example I added above will be enough for you to get started. If you run into problems, try adding log statements to the iRule to see what conditions are being met. The log output will be written to /var/log/ltm by default.
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