Forum Discussion
Maintenance page iRule. Need redirect AND rewrite.
Hi :)
I am looking to create an irule to throw a maintenance page redirect if our entire pool is down. This is what I have, which works.
when HTTP_REQUEST { Check if the VS default pool has no active members if { [active_members [LB::server pool]] < 1 }{ HTTP::redirect "http://maint.xyz.com" } }
The issue is, I need to be able to ALSO rewrite the url so that if the condition above is met, it redirects the user to maint.xyz.com and then rewrite their URL to www.xyz.com.
Thoughts?
Thanks!
OK, this is what i did which did the trick:
Added the maintenance server as a node on the LTM Create a pool called maintenance_pool and added my maintenance page server to it. Created an irule called maintenace_page with the following in it:
when HTTP_REQUEST { if {[active_members [LB::server pool]] < 1 } { pool maintenance_pool } }
Applied the rule to the Virtual servers needed. Voila. Works like a charm!
I really did not want to host the maintenance page on the LTM as we often change those pages and it is easier for the DEVs to do it directly on the server itself.
Thanks again for your help OTS02.
- OTS02Cirrus
Are maint.xyz.com and www.xyz.com both hosted on your LTM?
- OTS02Cirrus
I do not know of a way to do that. Once you redirect, you have no more control over their connection. May I ask why you want to do that? BTW, you can accomplish the redirect from the http profile, by placing 'maint.xyz.com' in the fallback host window.
- OTS02Cirrus
The LTM can serve out a good looking page (with images) from an iRule. It does take some doing though. You have to encode the images in base64 and load them into a class file. Here is a good link to some work that nitass has done: https://devcentral.f5.com/questions/maintenance-page
You will, of course, need to add some logic to keep an eye on the www.xyz.com pool. If you simply change the host header, after serving the maintenance page, you will create a race condition that will probably be terminated by the LTM.
- Leo_T_144084Altocumulus
I've been looking through your suggestion and working with Nitass' code. I was able to host the site on the LTM and get it to come up when all of the pool members come up, without images. Ideally, I would like to do this. Redirect to maint.xyz.com and replace the URL with www.xyz.com. Our maintenance pages often change so ideally I would redirect to a server with the maint page instead of having to recreate an irule every time the devs have to update the page. Of course the rewrite doesn't work.
when HTTP_REQUEST { Check if the VS default pool has no active members if { [active_members [LB::server pool]] < 1 }{ HTTP::redirect "http://maint.xyz.com" HTTP::header replace Host "www.xyz.com" } }
- chrenter_175530NimbostratusUsing these methods for pool failure, is there a way to redirect/rewrite to an internal web server without "redirect" to the client? We have a complex maintenance page that makes it extremely hard to maintain it on the F5. Right now, the following code triggers the condition, but the client receives connection reset. The intent is to have the F5 proxy the maintenance page. when HTTP_REQUEST { if {[active_members [LB::server pool]] < 1 } { pool maintenance_pool } } Thank you for any help!
- Leo_T_144084Altocumulus
OK, this is what i did which did the trick:
Added the maintenance server as a node on the LTM Create a pool called maintenance_pool and added my maintenance page server to it. Created an irule called maintenace_page with the following in it:
when HTTP_REQUEST { if {[active_members [LB::server pool]] < 1 } { pool maintenance_pool } }
Applied the rule to the Virtual servers needed. Voila. Works like a charm!
I really did not want to host the maintenance page on the LTM as we often change those pages and it is easier for the DEVs to do it directly on the server itself.
Thanks again for your help OTS02.
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