Forum Discussion
How to combine 2 iRules
I need help combining 2 iRules:
iRule 1:
when HTTP_REQUEST { if { [HTTP::host] equals "www.webpage.com" } { if { [HTTP::path] starts_with "/access/" } { log local0. "host=[HTTP::host] path=[HTTP::path] action=allow" return } } log local0. "host=[HTTP::host] path=[HTTP::path] action=reject" reject }
iRule 2
when HTTP_REQUEST { if { [HTTP::uri] contains "client_id=connection" } { log local0. "uri=[HTTP::uri] action=allow" return } else {
log local0. "Rejected"
reject
}
}
Thanks, Mark
9 Replies
- Arie
Altostratus
You could simply move the if-statement from the second rule into the first rule. However, there's a non-conditional "reject" command in the first rule that will reject all requests. Is this intentional?
rule 1:
when HTTP_REQUEST { if { [HTTP::host] equals "www.webpage.com" } { if { [HTTP::path] starts_with "/access/" } { log local0. "host=[HTTP::host] path=[HTTP::path] action=allow" return } } log local0. "host=[HTTP::host] path=[HTTP::path] action=reject" reject } - Mark_2014_16996
Nimbostratus
Thanks!
I need the iRule to just allow URL: www.webpage.com/access/.....client_id=connection
And reject all if it doesn't have host, www.webpage.com, URI, /access and string cleint_id=connection within the URL.
Another words, I'm just allowing 1 URL.
I tried moving the if statement but I got error messages.
- Mark_2014_16996
Nimbostratus
Arie - Thanks, I was able to move the if statement
- Arie
Altostratus
This should do it, then:
when HTTP_REQUEST { if { ( [HTTP::query] contains "client_id=connection" ) && ( [HTTP::path] starts_with "/access/" ) && ( [HTTP::host] equals "www.webpage.com" ) } { log local0. "uri=[HTTP::uri] action=allow" } else { log local0. "Rejected" reject } } - Arie
Altostratus
Better:
when HTTP_REQUEST { if { !( [HTTP::query] contains "client_id=connection" && [HTTP::path] starts_with "/access/" && [HTTP::host] equals "www.webpage.com" ) } { reject } } - Mark_2014_16996
Nimbostratus
Worked perfectly Arie - Thanks so much!!
- Arie
Altostratus
Great! Would you mind marking my reply as the answer?
- Mark_2014_16996
Nimbostratus
Sure...... but not sure how to do that but I'm assuming you mean to click the 'Check mark'?
- Arie
Altostratus
I believe so - thanks!
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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