Forum Discussion
Redirecting to an external site when the internal site is down
- Jun 06, 2023
John_Adams It seems like we cannot use a variable that has been created in that section of code. You can try the following to see if this works for you.
when HTTP_REQUEST priority 500 { if { [active_members [LB::server pool]] == 0 } { HTTP::respond 307 content { <html> <head> <title>Apology Page</title> </head> <body> We are sorry, but the site you are looking for is temporarily out of service<br> If you feel you have reached this page in error, please try again. </body> </html> } } }
Hi,
It's more than doable by irule and i'm sure in a built policy.
But how about these references for a start
https://my.f5.com/manage/s/article/K6510
https://www.youtube.com/watch?v=r-GndW4H3ck
https://www.youtube.com/watch?v=nJLK8G7eqbU
I've not looked at the youtube video's just search for them, but the f5 kb looks close to what you are looking for.
A policy may also be a quick fix to - i can find that method out to if you're not wanting to go down the irule route.
- John_AdamsJun 06, 2023Nimbostratus
Hi,
I see that first video shows the use of HTTP::respond instead of HTTP::fallback! That's perfect, because the request is to return a 307, and it appears HTTP::fallback only returns a 302.
Thanks,
John A
- PauliusJun 06, 2023MVP
John_Adams Typically this is achieved by using two pieces of configuration together.
1. The pool associated to the virtual server in question will have a health monitor for that site and if the response from the pool members is something other than what you define in the receive string then the pool member/s is/are considered down making the entire virtual server go down if the entire pool is down.
2. When the pool is completely down or the iRule defined criteria is met, such as less than 2 pool members of the over all pool members are available then you issue the redirect otherwise you just forward traffic to the pool and let load balancing occur.The following is an example iRule of how to perform this function with an example website. If you needed to narrow this down to a specific site and associate pool you could add in the additional matching criteria.
when CLIENT_ACCEPTED { set DEFAULT_POOL [LB::server pool] } when HTTP_REQUEST { if { [active_members [${DEFAULT_POOL}]] == 0 } { HTTP::respond 307 Temporary Redirect "http://www.example.com/" } }
- John_AdamsJun 06, 2023Nimbostratus
Hi, Paulius,
I've tried to implement this more or less as is:
when CLIENT_ACCEPTED {
set DEFAULT_POOL [LB::server pool]
}
when HTTP_REQUEST {
if { [active_members [${DEFAULT_POOL}]] == 0 } {
HTTP::respond 307 content {
<html>
<head>
<title>Apology Page</title>
</head>
<body>
We are sorry, but the site you are looking for is temporarily out of service<br>
If you feel you have reached this page in error, please try again.
</body>
</html>
}
}}
and I am getting an interesting error:
tmm1[12440]: 01220001:3: TCL error: /Common/_ualr_hostdown_307 <HTTP_REQUEST> - invalid command name "/Common/<app name>/<pool name>" while executing "${DEFAULT_POOL}"
I'm also getting it when I switch to the "Temporary Redirect <URL>" code you presented. Any thoughts?
Thanks,John A
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