23-Dec-2021
03:09
- last edited on
08-Feb-2022
14:17
by
JRahm
Hello,
I need on a VS 2 IRules, one for redirect to a URI and one for a Maintanance Page:
redirect:
when HTTP_REQUEST {
if { [HTTP::uri] equals "/"}
{
HTTP::redirect "https://[HTTP::host]/some-uri"
}
}
Maintanance Page:
when HTTP_REQUEST {
if { [active_members [LB::server pool]] < 1 } {
switch [HTTP::uri] {
"/bg-wappen.gif" {HTTP::respond 200 content [ifile get "bg-wappen.gif"]}
default {HTTP::respond 200 content {
<!DOCTYPE html>
...
but if I assign both IRules, if the backend server is down, the redirect doesn't work.
I tried with priority 10 in one IRule and 20 in the other IRule
Have you some suggestions for a solution? Both requirements in one Rule?
I've tried:
when HTTP_REQUEST {
if { [HTTP::uri] equals "/"}
{
HTTP::redirect "https://[HTTP::host]/some-uri"
}
if { [active_members [LB::server pool]] < 1 } {
switch [HTTP::uri] {
"/bg-wappen.gif" {HTTP::respond 200 content [ifile get "bg-wappen.gif"]}
default {HTTP::respond 200 content {
<!DOCTYPE html>
...
but didn't resolve
thank you
Solved! Go to Solution.
23-Dec-2021
05:49
- last edited on
08-Feb-2022
14:20
by
JRahm
Hi kgaigl,
I think a tcl error occurs. Can you investigate the ltm logs?
cat /var/log/ltm | grep "TCL error"
https://support.f5.com/csp/article/K23237429
Redirect:
when HTTP_REQUEST {
if { [HTTP::has_responded] } { return }
if { [HTTP::uri] equals "/" } {
HTTP::redirect "https://[HTTP::host]/some-uri"
return
}
}
Maintanance Page:
when HTTP_REQUEST priority 450 {
if { [HTTP::has_responded] } { return }
if { [active_members [LB::server pool]] < 1 } {
switch [HTTP::uri] {
"/bg-wappen.gif" { HTTP::respond 200 content [ifile get "bg-wappen.gif"] }
default { HTTP::respond 200 content {
<!DOCTYPE html>
...
Combined:
when HTTP_REQUEST {
if { [HTTP::has_responded] } { return }
if { [HTTP::uri] equals "/" } {
HTTP::redirect "https://[HTTP::host]/some-uri"
return
}
elseif { [active_members [LB::server pool]] < 1 } {
switch [HTTP::uri] {
"/bg-wappen.gif" { HTTP::respond 200 content [ifile get "bg-wappen.gif"] }
default { HTTP::respond 200 content {
<!DOCTYPE html>
...
23-Dec-2021
05:49
- last edited on
08-Feb-2022
14:20
by
JRahm
Hi kgaigl,
I think a tcl error occurs. Can you investigate the ltm logs?
cat /var/log/ltm | grep "TCL error"
https://support.f5.com/csp/article/K23237429
Redirect:
when HTTP_REQUEST {
if { [HTTP::has_responded] } { return }
if { [HTTP::uri] equals "/" } {
HTTP::redirect "https://[HTTP::host]/some-uri"
return
}
}
Maintanance Page:
when HTTP_REQUEST priority 450 {
if { [HTTP::has_responded] } { return }
if { [active_members [LB::server pool]] < 1 } {
switch [HTTP::uri] {
"/bg-wappen.gif" { HTTP::respond 200 content [ifile get "bg-wappen.gif"] }
default { HTTP::respond 200 content {
<!DOCTYPE html>
...
Combined:
when HTTP_REQUEST {
if { [HTTP::has_responded] } { return }
if { [HTTP::uri] equals "/" } {
HTTP::redirect "https://[HTTP::host]/some-uri"
return
}
elseif { [active_members [LB::server pool]] < 1 } {
switch [HTTP::uri] {
"/bg-wappen.gif" { HTTP::respond 200 content [ifile get "bg-wappen.gif"] }
default { HTTP::respond 200 content {
<!DOCTYPE html>
...
26-Dec-2021 23:25
Hi Enes,
the combined Rule is working fine.
Thank you
Karl
27-Dec-2021 07:51
Hi,
Can you share the iRules?
08-Mar-2023 03:25
what is reason behind i cannot use 2 separate http request irule in version 16 , 2 http request irule i used in version 13