Forum Discussion
jay_41157
Nimbostratus
Aug 28, 2008can this Irule be optimized?
when HTTP_REQUEST {
if { [matchclass [string tolower [HTTP::uri]] starts_with $::legacyPaths] } {
checked for matchclass == legacyPaths and forward to Legacy_http_pool
snat 172.23.0.60
HTTP::header insert X-Forwarded-For [IP::remote_addr] this was done to test i am trying to do it using http profile..
used for debub
HTTP::redirect http://www.google.com
pool Legacy_http_pool
} else {
when uri matches admin in Literatum check for source ip
if { [HTTP::uri] starts_with "/admin" and (not [matchclass [IP::remote_addr] equals $::Admin]) } {
path for admin uri but not internal IP
log local0. "External IP ([IP::remote_addr]) attempting to access admin path ([HTTP::uri])"
HTTP::redirect http://redirect.com/404.html
} else {
pool Stage_http_pool
}
}
}
---------------Thanks
Also I am using a custom http profile for this, where I am using insert X-forward-for. When I try to check for X-forward-for in fiddler (ie) or live headers in firefox I do not see it there... should I ?
THanks
7 Replies
Sort By
- Nicolas_Menant
Employee
This iRule looks good. Maybe just add a [string tolower [HTTP::uri]] in your if statemement:when HTTP_REQUEST { if { [matchclass [string tolower [HTTP::uri]] starts_with $::legacyPaths] } { checked for matchclass == legacyPaths and forward to Legacy_http_pool snat 172.23.0.60 HTTP::header insert X-Forwarded-For [IP::remote_addr] this was done to test i am trying to do it using http profile.. used for debub HTTP::redirect http://www.google.com pool Legacy_http_pool } else { when uri matches admin in Literatum check for source ip if { [string tolower [HTTP::uri]] starts_with "/admin" and (not [matchclass [IP::remote_addr] equals $::Admin]) } { path for admin uri but not internal IP log local0. "External IP ([IP::remote_addr]) attempting to access admin path ([HTTP::uri])" HTTP::redirect http://redirect.com/404.html } else { pool Stage_http_pool } } }
- jay_41157
Nimbostratus
Thanks I am not sure how the tolower got missed, i will add it. - jay_41157
Nimbostratus
This is the updated IRULE for above .... thoughts / comments / suggestions please. - hoolio
Cirrostratus
Assuming the logic works for your scenario, the syntax looks fine.when HTTP_REQUEST { if { (not [matchclass [string tolower [HTTP::uri]] starts_with $::LegacyExceptions]) and ([matchclass [string tolower [HTTP::uri]] starts_with $::LegacyPaths]) } { checked for matchclass != exceptions and == LegacyPaths and forward to Legacy_http_pool use snatpool atypon_SNAT log local0. "*****DEBUG SNAT applied" snat 172.23.0.60 pool Legacy_http_pool HTTP::redirect http://www.google.com } else { when uri matches admin in Literatum check for source ip if { [HTTP::uri] starts_with "/admin" and (not [matchclass [IP::remote_addr] equals $::Admin]) } { Literatum path for admin uri but not internal IP log local0. "External IP ([IP::remote_addr]) attempting to access admin path ([HTTP::uri])" HTTP::redirect http://redirect.com/404.html } else { pool Stage_http_pool } } }
- jay_41157
Nimbostratus
Aaron thanks for verifying the syntax, I was more curious if there would be any optimization that can be done .... - jay_41157
Nimbostratus
ok, so now we need ...... - hoolio
Cirrostratus
I think the rule was as efficient as it could be.
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