Forum Discussion
iRules when pool member is down
I used below irule so if both pool members failed then F5 iRule due redirect to another page which is hosting on another server.
when HTTP_REQUEST { if { [active_members My_APACHE_SAT_8443_Pool ] < 1 } { HTTP::redirect "http://example-test.com/" } }
well, it did not happened as I got a call from application owner that maintenance page didn't work, I looked at F5 logs and I noticed below error in F5 logs. - Operation not supported. Multiple redirect/respond invocations not allowed (line 1) invoked
I already have another irule on same VIP which is sending all / to login.aspx. we had same configs in our SAT and works fine. it appears there is another redirect happening perhaps on server site?
where can I start? I am sure the issue might be on server or applications.
6 Replies
- KJ_50941
Nimbostratus
the other iRule on sane VIP is : when HTTP_REQUEST { if { [HTTP::uri] eq "/" } { HTTP::redirect https://[HTTP::host]/help/html } }
so we have both iRule on same VIP, is that the problem, and if I need to put both in one iRule how can this be accomplished?
Thx, ALL
- THi
Nimbostratus
I have had similar experiences when iRule logic creates a conflict situation when multiple rules are firing at the same event for a single request. What happens when the user requests "/" AND all members in the pool are down. Which redirection to follow?
You can combine those two iRules together, so that there is no logic conflict. Obviously - if no pool members are available then redirect to the maintenance page - else if uri is "/" then redirect to help page
I leave the exact syntax for you for exercise.. ;o)
- KJ_50941
Nimbostratus
Thx
I combine both irules, but I am getting syntax error ( maintenance_and_redirect:4: error: [missing a script after "else"][]), below is combine irule.
when HTTP_REQUEST { if { [active_members My_APACHE_SAT_8443_Pool ] < 1 } { HTTP::redirect "http:// http://example-test.com/} {
} else if { [HTTP::uri] eq "/" } { HTTP::redirect https://[HTTP::host]/help/html } } - THi
Nimbostratus
You have some syntax errors, for example else if should be written together "elseif" and also directly to the line of closing the main if branch. Try:
when HTTP_REQUEST { if { [active_members My_APACHE_SAT_8443_Pool] < 1 } { HTTP::redirect http://example-test.com/ } elseif { [HTTP::uri] eq "/" } { HTTP::redirect https://[HTTP::host]/help/html } }That passes syntax check on TMOS version 11.5.1 on my lab unit. You can refer to iRules Wiki
- THi
Nimbostratus
Syntactically you can also use nested if statements:
when HTTP_REQUEST { if { [active_members My_APACHE_SAT_8443_Pool] < 1 } { HTTP::redirect http://example-test.com/ } else { if { [HTTP::uri] eq "/" } { HTTP::redirect https://[HTTP::host]/help/html } } }Don't know the actual implementation on F5 TCL, but the former might be a bit more compact and use less CPU cycles. If needed you can add a final else, too. If you need more redirects based on the path, you might use switch statement instead of nested if.
- KJ_50941
Nimbostratus
Thank you so much.
it did take the iRule , I am testing during application maintenance window. I notice if I go to F5 VIP is redirect me to another application which is acting as web gate for authentication. I am hopping this will fix it .
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