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, 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
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>
}
}
}
- John_AdamsJun 06, 2023Altostratus
Paulius, I'm now getting no errors and the apology text in Safari, Firefox, and Chrome, which is clear progress and fulfills my specific task.
One oddity: When I tried the "Temporary Redirect <URL>" code you offered, I get no errors and blank screens with all browsers. It's throwing up that apology message that I've been asked to do, but I'm still curious about the other syntax and why it's not working. It seems very straightforward and I don't believe I have any typos.
- PauliusJun 07, 2023MVP
John_Adams My mistake on this one. Because you're wanting the F5 to serve a generic website you should do the following instead of a 307. You would use the redirect if you were sending a new URL to the client but in this case you are sending a basic website.
when HTTP_REQUEST priority 500 { if { [active_members [LB::server pool]] == 0 } { HTTP::respond 200 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> } } }
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