Forum Discussion
Ido_Katz_38061
Nimbostratus
May 05, 2010Help
Hi Guys,
1st of all I want to tell you that you got great community, you doing a great job!
2nd of all...I have a little problem that I'm sure that one of you can help me, I can't save the IRule because i'm getting confused with the braces.
The IRule going like that:
when HTTP_REQUEST {
if {[ HTTP::header exists "subscriberID" ]}
if {[matchclass [HTTP::header "subscriberID"] equals $::subscriberID]}
{pool AA-BB-Pool}
else { HTTP::respond 301 Location "http://XYZ.com" )
elseif {[matchclass [IP::client_addr] equals $::GGG]}
{ log local0. "Valid Source IP: [IP::client_addr] - forwarding traffic"
pool AA-BB-Pool}
else { HTTP::respond 301 Location "http://XYZ.com" } log local0. "INVALID Source IP: [IP::client_addr] - dropping traffic"
Can someone please help me?
Thanks
Ido
5 Replies
- Cspillane_18296
Nimbostratus
Hello Ido, try this I think it'll work (at least the iRule editor gives me no complaints!!):
when HTTP_REQUEST {
if { [matchclass [HTTP::header "subscriberID"] equals $::subscriberID]} {
{pool AA-BB-Pool}
else { HTTP::respond 301 Location "http://XYZ.com" target="_blank" rel="nofollow">http://XYZ.com" )
elseif {[matchclass [IP::client_addr] equals $::GGG]}
log local0. "Valid Source IP: [IP::client_addr] - forwarding traffic"
pool AA-BB-Pool}
else { HTTP::respond 301 Location "http://XYZ.com" target="_blank" rel="nofollow">http://XYZ.com" } log local0. "INVALID Source IP: [IP::client_addr] - dropping traffic"
}
}
However, I don't think you needed the first 'if' statement so I have removed it if {[ HTTP::header exists "subscriberID" ]} although one of the more experienced chaps may be able to guide you better on that. Let us know how you get on. - Ido_Katz_38061
Nimbostratus
Hi There,
I have been told that I have to put this line in the begining,could someone please advise with the 1st line?
Thanks a lot for your help
Ido
---------------------------------------------------------------------------------------------------------
I tryied this one:
when HTTP_REQUEST {
if [ HTTP::header exists "subscriberID" ] } {
if [matchclass [HTTP::header "subscriberID"] equals $::subscriberID]} {
pool AA-BB-Pool} {
else {HTTP::respond 301 Location "http://XYZ.com" }
elseif { [matchclass [IP::client_addr] equals $::XXX] } {
log local0. "Valid Source IP: [IP::client_addr] - forwarding traffic"
pool AA-BB-Pool} {
else { HTTP::respond 301 Location "http://XYZ.com" }
log local0. "INVALID Source IP: [IP::client_addr] - dropping traffic" }
But I can't save it because of brace's problem.
Thanks a lot for your help. - Cspillane_18296
Nimbostratus
Hi Ido,
the following is a valid rule, does this achieve your requirements?
when HTTP_REQUEST {
if { [matchclass [HTTP::header exists "subscriberID"] equals $::subscriberID] } {
pool AA-BB-Pool
} elseif { [matchclass [IP::client_addr] equals $::XXX] } {
log local0. "Valid Source IP: [IP::client_addr] - forwarding traffic"
pool AA-BB-Pool
} else { HTTP::respond 301 Location "http://XYZ.com" }
log local0. "INVALID Source IP: [IP::client_addr] - dropping traffic" }
I am afraid that I have little experience in the use of classes, but to my eye this looks like it should do the job - I'm sure someone will correct my inaccuracies!
As you can see i have removed a couple of lines in an effort to make the rule more efficient (the http::respond command is surely only needed if we don't match the class for the subscriberID or the valid source IP?).
Thanks and good luck in your testing. - Ido_Katz_38061
Nimbostratus
Please try to keep the stracture as it is, I need this Irule to be as I wrote.
Can you please help me?
I'm sorry for sounding bad and a pain in the ass.
But I really need it to work as it is.
Thanks
Ido - hoolio
Cirrostratus
Maybe something like this?when HTTP_REQUEST { if {[HTTP::header exists "subscriberID"]}{ if {[matchclass [HTTP::header "subscriberID"] equals $::subscriberID]}{ pool AA-BB-Pool } else { HTTP::respond 301 Location "http://XYZ.com" } } elseif {[matchclass [IP::client_addr] equals $::XXX]}{ log local0. "Valid Source IP: [IP::client_addr] - forwarding traffic" pool AA-BB-Pool } else { HTTP::respond 301 Location "http://XYZ.com" log local0. "INVALID Source IP: [IP::client_addr] - dropping traffic" } }
Note that you can use [ code ] [ /code ] tags (without the spaces) to preserve the indentation of your rule code. This makes it a lot easier to see the nesting of braces.
Aaron
Recent Discussions
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
