Forum Discussion
redirect not working
Thanks for your response , above logic works only when pool1 members are not equal to zero then simply it goes to uri redirect ,but when the else condition is met and traffic is going to pool2 , i even want the HTTP::redirect "https://[HTTP::host]/testpage". If I apply If for pool2 too its not working .Can you assist me.
If that's the case then your original iRule with the "==" correction on the URI match should work. I have also made some formatting changes as well so I would use the iRule in this comment.
when HTTP_REQUEST priority 500 {
if { [HTTP::uri] == "/" } {
HTTP::redirect "http://[HTTP::host]/testpage"
}
if { [active_members pool1] == 0 } {
if { ( ( [class -- match [IP::client_addr] == "whitelist"] ) && ( [active_members pool2 ] > 0 ) ) } {
pool pool2
} else {
HTTP::respond 503 content [ifile get "applicationdown.html"]
}
}
}
- sandikskMay 09, 2024Nimbostratus
redirect is working as expected but when both pools are down i dont see traffic going to HTTP::respond 503 content [ifile get "applicationdown.html"] . I get connection reset can't reach the page.
when HTTP_REQUEST priority 500 {if { [HTTP::uri] == "/" } {
HTTP::redirect "https://[HTTP::host]/testpage"
}
if { [active_members pool1] == 0 }{
if { ( ( [class match [IP::client_addr] eq "whitelist"] ) && ( [active_members pool2 ] > 0 ) ) }
{ pool pool2
}
else {
log local0. "applicationdown"
HTTP::respond 503 content [ifile get "applicationdown.html"]
}
}
}lb err tmm[31148]: 01220001:3: TCL error: /Common/applicationdown-irule <HTTP_REQUEST> - Operation not supported. Multiple redirect/respond invocations not allowed (line 1) invoked from within "HTTP::respond 503 content [ifile get "applicationdown.html"]"
lb err tmm[31148]: 01220001:3: TCL error: /Common/applicationdown-irule <HTTP_REQUEST> - Operation not supported. Multiple redirect/respond invocations not allowed (line 10) invoked from within "HTTP::respond 503 content [ifile get "applicationdown.html"]"- PauliusMay 09, 2024MVP
In the iRule you posted it seems you have a few syntax issues. Try copying the following iRule and see if your issue is resolved.
when HTTP_REQUEST priority 500 { if { [HTTP::uri] == "/" } { HTTP::redirect "https://[HTTP::host]/testpage" } if { [active_members pool1] == 0 } { if { ( ( [class -- match [IP::client_addr] == "whitelist"] ) && ( [active_members pool2 ] > 0 ) ) } { pool pool2 } else { log local0. "applicationdown" HTTP::respond 503 content [ifile get "applicationdown.html"] } } }
- sandikskMay 09, 2024Nimbostratus
Paulius , thankyou so much for looking into this , but the problem with the above logic is when both the pools are down users still need to get the maintenance page but when i try accessing the url abc.test.com -- I get connection rest page cannot be displayed when i access https://abc.test.com/testpage --- it displays me the application down message from the log statement . Dont see any issues with the syntax of the above irule but when both pools are down i see vip is marked down so the else statment is not getting executed i guess.
tmm[31148]: 01220001:3: TCL error: /Common/test-irule <HTTP_REQUEST> - Operation not supported. Multiple redirect/respond invocations not allowed (line 10) invoked from within "HTTP::respond 503 content [ifile get "applicationdown.html"]"
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