when HTTP_REQUEST {
if {[LB::status pool Server_HTTP] == "down" } {
set HOST [HTTP::host]
set REDIRECTHOST ""
switch [HTTP::host] {
www.abc.com { set REDIRECTHOST "maintenance.abc.com" }
www.def.com { set REDIRECTHOST "maintenance.def.com" }
www.ghi.com { set REDIRECTHOST "maintenance.ghi.com" }
default { log "Unknown HTTP::host $HOST cannot redirect, rejecting connection."
reject }
}
HTTP::respond 302 Location "$REDIRECTHOST"
}
}
Or you could have the A10 generate the maintenance page for you?
HTTP::respond 503 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.<p></body></html>"
If you always remove the www and put "maintenance" in front of the hostname you could also look at using regsub to replace "www." in the host with "maintenance.".
An easier, and generally more efficient way, to do redirect to URL when the service-group is down (usually because all the servers in that group are down) is to use an HTTP template.
The . . . stuff is a stand-in for other needed or desired configuration. In the case of the template http, maybe the only feature you want to use is failover-url, which is fine.
I have seen the failover-url used in two basic ways (although I am sure there are more)
1. Lots of vPorts redirect to the same "fail-whale" page somewhere else 2. There are 2 data-centers, perhaps we're using GSLB, and each location redirects to a specific URL that resolves to another data-center, something like east.www.example.com and west.www.example.com. Of course, there is a bunch more DNS related config to make such a design work.
I'm afraid you are still using the wrong quotation marks, and you do not need to put quotation marks around the pool name.
Do not use word/wordpad or any other word processing tool that wants to intelligently look at your text. You need a plain-text editor or a code-writing tool that does not adjust the quotations to an open and close version.
The neutral (vertical) quotation mark is used in coding.
Your code needs to look like this:
when HTTP_REQUEST {
if {[LB::status pool dlteam-group108_port443] == "down" } {
HTTP::redirect "http://maintenance.example.com/maintenance.html"
}
}
Comments
You can use something like this:
Use the HTTP response code that suits your requirements best.
Google & Github are your friend
https://github.com/a10networks/aflex-collection
https://www.a10networks.com/resources/articles/aflex-examples
Thank you for the info and so I can put like this?
when HTTP_REQUEST {
if {[LB::status pool Server_HTTP] == "down" } {
HTTP::respond 302 Location "https://backup.example.com"
}
}
Thank you
" "
are the correct ones though.See the difference in your post and mine.
How about this case, can I setup redirect for each web site?
1 VIP 205.222.120.38
2 real servers web001.com 10.1.1.1 web002.com 10.1.1.2
hosting multiple web sites on same service-group (server-http)
https://www.abc.com -> redirect to maintenance.abc.com
https://www.def.com -> redirect to maintenance.def.com
https://www.ghi.com -> redirect to maintenance.ghi.com
Is it possible?
Thank you
Or like this:
Or you could have the A10 generate the maintenance page for you?
If you always remove the www and put "maintenance" in front of the hostname you could also look at using
regsub
to replace "www." in the host with "maintenance.".When I applied this aflex,
when HTTP_REQUEST {
if
{[LB::status pool dlteam-group108_port443] == “down” }
{ HTTP::redirect “http://maintenance.example.com/maintenance.html” }
}
This error massage showed up
Warning: aFleX syntax error: line 3: "wrong # args: no expression after "if" argument"
dlteam-group108_port443 is service-group name
Thank you
Note the difference between:
if {[LB::status pool Server_HTTP] == "down" } {
and you version:
You need to use
""
And you are missing a {
The
. . .
stuff is a stand-in for other needed or desired configuration. In the case of thetemplate http
, maybe the only feature you want to use isfailover-url
, which is fine.I have seen the
failover-url
used in two basic ways (although I am sure there are more)1. Lots of vPorts redirect to the same "fail-whale" page somewhere else
2. There are 2 data-centers, perhaps we're using GSLB, and each location redirects to a specific URL that resolves to another data-center, something like
east.www.example.com
andwest.www.example.com
. Of course, there is a bunch more DNS related config to make such a design work.Warning: aFleX syntax error: line 3: "syntax error in expression "[LB::status pool “dlteam-group108_port443”]...""
Thank you
Do not use word/wordpad or any other word processing tool that wants to intelligently look at your text. You need a plain-text editor or a code-writing tool that does not adjust the quotations to an open and close version.
The neutral (vertical) quotation mark is used in coding.
Your code needs to look like this: