Forum Discussion
need to rewrite HTTP 200 status code to HTTP 503
Hello,
I am performing website maintenance and need to bring down our website for a few hours. I will be
serving a friendly maintenance page during this time. However, when Google comes by during the
maintenance period this will present a problem for indexing. I am running BigIP version 10.2.3
Google strongly recommends that we return a 503 HTTP result code during the maintenance window:
http://googlewebmastercentral.blogs...anned-site-
downtime.htmlhttp://googlewebmastercentral.blogspot.com/2011/01/how-to-deal-with-planned-site-
downtime.html
There are similiar posts to mine in these forums, but none resolve what I am trying to do. I want to
serve a maintenance page from a pool in VIP and have the F5 rewrite the result code from a 200 to a 503.
I am able to apply the iRule to the VIP, however, it does not serve my maintenance page. This is my
iRule:
when HTTP_REQUEST {
HTTP::respond 503 noserver Retry-After: 10800
}
Thanks,
16 Replies
- Richard__HarlanHistoric F5 AccountIn your iRule you are sending a respond to the request so the LTM will not send the request to the pool. This pop up awhile ago to the iRule and did a small change so it should work in your setup.
https://devcentral.f5.com/Community/GroupDetails/tabid/1082223/asg/39/aft/5814/showtab/groupforums/Default.aspx
when HTTP_REQUEST_SEND {
TCP::collect 12
}
when SERVER_DATA {
if {[findstr [TCP::payload 12] "200"] == "200"} {
TCP::payload replace 9 3 "503"
}
} - hoolio
Cirrostratus
Hi Jason,
Do you see any errors in /var/log/ltm when you test that iRule? Are there other iRules or HTTP profile config options that might be sending a redirect? If so, you could disable all other iRules when you're using the maintenance iRule using event disable all:https://devcentral.f5.com/wiki/iRules.event.ashx when HTTP_REQUEST { HTTP::respond 503 noserver Retry-After: 10800 event disable all }
Aaron - hoolio
Cirrostratus
Richard's right and has a good example. I missed that you wanted to just rewrite the pool member's status code.
There's an existing Request For Enhancement for rewriting the status code using HTTP::status $new_status_code:
BZ385613 RFE: Make HTTP::status iRule command support writing data
You can open a case with F5 Support to add your request to the RFE and raise its visibility.
Aaron - jasona_40790
Nimbostratus
Thanks much, that worked. I will also need to set the 503 'Retry-After header' with something similiar to this:
Retry-After: Fri, 15 Jun 2012 13:00:00 GMT
Where would I put this 'Retry-After header' in the example you gave me.
Thanks,
Jason - Richard__HarlanHistoric F5 AccountIn the HTTP_REQUEST_SEND you can add the header with the following command
if { [HTTP::header exists "Retry-After"] } {
HTTP::header replace Retry-After 10800
} else {
HTTP::header insert Retry-After: 10800
} - jasona_40790
Nimbostratus
Thanks Richard,
Well, I added the 'Retry-After' code to my iRule and, while the iRule syntax accepted it, the maintenance page in the VIP is not accessible. I've posted my entire iRule. If I put the 'Retry-After' code anywhere else in the HTTP_REQUEST_SEND section, the iRule syntax will not accept it.
when HTTP_REQUEST_SEND {
if { [HTTP::header exists "Retry-After"] } {
HTTP::header replace Retry-After 10800
} else {
HTTP::header insert Retry-After: 10800
}
TCP::collect 12
}
when SERVER_DATA {
if {[findstr [TCP::payload 12] "200"] == "200"} {
TCP::payload replace 9 3 "503"
}
} - Richard__HarlanHistoric F5 AccountCan you post the error in /var/log/ltm. Most likely I over looked a syntex error whihc will cause the LTM to reset the connection and not display the page.
- jasona_40790
Nimbostratus
TCL error: iRule-Downtime503 - Illegal argument. Can't execute in the current context. (line 1) invoked from within "HTTP::header exists "Retry-After""
Jun 14 16:04:18 local/tmm err tmm[7807]: 01220001:3: TCL error: iRule-Downtime503 - Illegal argument. Can't execute in the curre nt context. (line 1) invoked from within "HTTP::header exists "Retry-After"" - Richard__HarlanHistoric F5 AccountOk it does not like the HTTP::header exists
I read through the WIKI and it looks like that is redundant all you have to run is the following
HTTP::header replace Retry-After: 10800
if the header is not there it will add if it is then it will update.
Sorry about that. - jasona_40790
Nimbostratus
Richard,
Still not working. Here is the /var/log/ltm:
Jun 14 17:18:56 local/tmm1 err tmm1[7808]: 01220001:3: TCL error: iRule-Downtime503 - Illegal argument. Can't execute in the current context. (line 1) invoked from within "HTTP::header replace Retry-After: 10800"
Here is the iRule:
when HTTP_REQUEST_SEND {
HTTP::header replace Retry-After: 10800
TCP::collect 12
}
when SERVER_DATA {
if {[findstr [TCP::payload 12] "200"] == "200"} {
TCP::payload replace 9 3 "503"
}
}
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
