Forum Discussion
Kindly Guide How to add Error 500 alongwith Existing Error 503 into the Irule
Hi Team,
Kindly Guide How to add Error 500 alongwith Existing Error 503 into the below Irule and also to remove the Set-Cookie BIGipServervs_http part, I tried but I failed as its showing syntax error, kindly guide as I am new to this Irule:
Don't send 503 errors out, try next server. After 10 consecutive failed attempts, send redirect
when HTTP_REQUEST priority 700 { set my_url [HTTP::host][HTTP::uri] if { [HTTP::cookie BIGipServervs_http] contains "Redirect" } { set count [findstr [HTTP::cookie BIGipServervs_http] "Redirect_" 15 1]
log local0. "Variable count set to: $count"
} else { set count 0 } } when HTTP_RESPONSE priority 700 { if { [HTTP::status] == 503 && $count < 15 } { incr count HTTP::respond 302 Location "http://$my_url" Set-Cookie "BIGipServervs_http=Redirect_$count" Connection "Close" event disable } elseif { [HTTP::status] == 503 && $count == 15 } { set count 0
log local0. "Sending to Main Page"
HTTP::respond 302 Location "http://www.xyz.com" Set-Cookie "BIGipServervs_http=Redirect_$count" Connection "Close" event disable } }
Thanks and Regards Parveez
9 Replies
- JG
Cumulonimbus
I don't think yours will work as it is. Check this one out instead:
https://devcentral.f5.com/wiki/iRules.http__retry.ashx - JG
Cumulonimbus
How about this, based on your current version:
Don't send 503 or 500 errors out, try next server. After 10 consecutive failed attempts, send redirect when HTTP_REQUEST priority 700 { set my_url [HTTP::host][HTTP::uri] } when HTTP_RESPONSE priority 700 { if { ( ( [HTTP::status] == 503 ) or ( [HTTP::status] == 500 ) ) && ( $count < 15 ) } { incr count HTTP::respond 302 Location "http://$my_url" event disable } elseif { ( ( [HTTP::status] == 503 ) or ( [HTTP::status] == 500 ) ) && ( $count == 15 ) } { set count 0 log local0. "Sending to Main Page" HTTP::respond 302 Location "http://www.lenovo.com" event disable } } when HTTP_RESPONSE priority 800 { if { ( ( [HTTP::status] == 500 ) or ( [HTTP::status] == 500 ) ) && ( $count < 15 ) } { incr count HTTP::respond 302 Location "http://$my_url" event disable } elseif { ( ( [HTTP::status] == 500 ) or ( [HTTP::status] == 503 ) ) && ( $count == 15 ) } { set count 0 log local0. "Sending to Main Page" HTTP::respond 302 Location "http://www.lenovo.com" event disable } } - Parveez_70209
Nimbostratus
Ok, thanks.
One more thing, need to create one advanced monitor where we need to edit a receive string which will track 503 error which will mark the member-server down.
Thanks and Regards Parveez
- Parveez_70209
Nimbostratus
Hi Jie/Team,
The Irule suggested is quite valid it seems but to make that Irule work:
1.We are planning to attach an advanced monitor having some Advanced Receive String which will catch any 500.* error. Kindly assist into the syntax/format of the Receive String. 2.Once that caught it will shut down one by one every single server into the pool as per the Irule, and once all member-server got down, it should display the Apology Page which will come from an Irule, either banner based which Load-Balancer will take-care or by creating an Irule which is containing APOLOGY Member-server pool having rule:
if { [active_members [LB::server pool]] <= 0 }
Thanks and Regards Parveez
- JG
Cumulonimbus
I thought you had some special requirement, but it seems now what you really needed could be met with the basic, if not the alright default, configuration of a pool-level health monitor. See http://support.f5.com/kb/en-us/products/lc_9_x/manuals/product/lc_config_guide_10_1/lc_monitors.html on how to set one up.
You can define a fallback host to serve the error/downtime page in an HTTP profile. If you want a dynamic, inline sorry page, this is one of the most FAQ'ed here on this forum. Here's one example: https://devcentral.f5.com/wiki/irules.Automatic_maintenance_page___Sorry_page_with_images.ashx . You can find more examples by using the search facility.
- Parveez_70209
Nimbostratus
Hi Jie,
I sorted out many of the things, just wanted your assistance in to receive string in Advanced HTTP Monitor to catch all 500.* and 503* related errors from destination member-servers.
Thanks and Regards
- JG
Cumulonimbus
What does your current monitor look like? Are you also trying to make the monitor try 10 times if it fails as well? :-) Sorry, I just can't understand what prompts you do all this. You must have a very unreliable service at the backend, and it seems to me you ought to have more fundamental problems or fussy customers to address instead. :-)
- Parveez_70209
Nimbostratus
Hi Jie,
🙂 True.. Our requirement is as below:
- In-case of any 500 or 503 error coming from destination member-servers, the mechanism is to make that server hard down and move to next server after trying 15 times before making it down. For this we have the below Irule which you assisted earlier:
when HTTP_REQUEST priority 700 { set my_url [HTTP::host][HTTP::uri] }
when HTTP_RESPONSE priority 700 { if { ( ( [HTTP::status] == 503 ) or ( [HTTP::status] == 500 ) ) && ( $count < 15 ) } { incr count HTTP::respond 302 Location "http://$my_url" event disable } elseif { ( ( [HTTP::status] == 503 ) or ( [HTTP::status] == 500 ) ) && ( $count == 15 ) } { set count 0
log local0. "Sending to Main Page"HTTP::respond 302 Location "http://www.xyz.com" event disable }}
But to work this well, if not wrong : definitely we need to have some kind of advanced monitor which will track the 500 or 503 errors by some syntax of receive string from member-servers.
2.Currently the application member-servers as well as the APOLOGY-Page member-server( which is holding Maintenance-Page) is into the same pool.
For this we are planning to create Priority Activation Groups, where the application member-servers will hold a higher Priority Activation Group than the APOLOGY-Page member-server's Priority Group.
So, thats the reason we are looking for advanced monitor which can track the 500.* and 503.* errors from end member-servers.
Yes, we can go with Fallback host where we can specify the fallback errors( for eg 500;503), but this may hamper the existing concept of Irule which is tracking the errors: 500 and 503).
Thanks and Regards Parveez
- Parveez_70209
Nimbostratus
Hi Team,
Kindly guide regarding the advanced monitor.
Thanks and Regards Parveez
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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