Forum Discussion
Brett__01_13258
Oct 20, 2015Nimbostratus
2 http request rules merge to one - one referer the other set access only
Hi I have two rules that work individually. But when i try and combine get no luck and just redirects everything to the default location.
The first rule is to only allow the uri path in the irule,...
JRahm
Oct 20, 2015Admin
I normally prefer a switch over if/else, but in your case, multiple conditions aren't as pretty as to combine you'd end up with nested switch statements. Doable, but ugly. It looks like the flow is:
- Make sure the path is allowed, if not, redirect to
- If the path has already been verified as allowed, check that the referer header contains (X)
- If it doesn't, proceed
- If it does, redirect to http://goodlocation.com
If this is the case, I'd simplify all the logic down to two data-groups and a short iRule:
ltm data-group internal allowed_paths {
records {
/path1/path2/path3 { }
/path1/path2/path5 { }
/path4/path2/path3 { }
/path4/path2/path5 { }
}
type string
}
ltm data-group internal login_required_paths {
records {
anothergoodlocation.com { }
goodlocation.com { }
youcanalsologin.com { }
}
type string
}
when HTTP_REQUEST {
if { [class match [string tolower [HTTP::uri]] starts_with allowed_paths] } {
if { [class match [strint tolower [URI::host [HTTP::header "Referer"]] starts_with login_required_paths] } {
HTTP::redirect "http://goodlocation.com"
}
} else { HTTP::redirect "http://www.notallowed.asp" }
}
This assumes of course you have defined pool POOL_Servers_to_access-80 as the default pool on your virtual server.
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