# Hosting Sorry, Error, or Maintenance Pages on BIG-IP LTM with iRules

**URL:** <https://community.f5.com/t/hosting-sorry-error-or-maintenance-pages-on-big-ip-ltm-with-irules/67814>\
**Category:** F5 Technical Articles\
**Tags:** availability, irules, dev, perl, development, devops, application-delivery, us\
**Created:** [June 15, 2011, 1:04am UTC](https://community.f5.com/t/hosting-sorry-error-or-maintenance-pages-on-big-ip-ltm-with-irules/67814 "2011-06-15T01:04:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JRahm](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/jrahm/32/3327_2.png) [@JRahm](https://community.f5.com/u/JRahm)\
**Post date:** [June 15, 2011, 1:04am UTC](https://community.f5.com/t/hosting-sorry-error-or-maintenance-pages-on-big-ip-ltm-with-irules/67814/1 "2011-06-15T01:04:00Z")

</div>

#### Note

Whereas you can still customize your BIG-IP with perl-scripts and sorry pages in this way, F5 has made this far easier with iFiles, introduced in 11.1. [This tech tip on iFiles](https://devcentral.f5.com/s/tech-tips/articles/v111-ndashexternal-file-access-from-irules-via-ifiles) should be the recommended path for sorry pages going forward.

I’ve posted on this before ([Host that Sorry Page on your BIG-IP!](https://devcentral.f5.com/s/weblogs/jason/archive/2009/05/12/host-that-sorry-page-on-your-big-ip.aspx)) but it’s been a while and there have been a few updates. Besides, narrowing the application to only sorry pages is a bit myopic—I’m sure my BIG-IP is offended that I treated it so callously. Anyway, I got an inquiry a week or so ago about the images in tables not being picked up by the script. The images in the table were referenced as such:

> ```auto
> #<span style="color: #0000ff;"><</span><span style="color: #800000;">table</span> <span style="color: #ff0000;">background</span><span style="color: #0000ff;">="genericofflinebackground.gif"</span> <span style="color: #ff0000;">align</span><span style="color: #0000ff;">="center"</span> <span style="color: #ff0000;">width</span><span style="color: #0000ff;">="1024"</span> <span style="color: #ff0000;">height</span><span style="color: #0000ff;">="768"</span> <span style="color: #0000ff;">></span>
> 
> ```

I reached out to the author, Kirk Bauer, and he gave me some pointers as where to look. There’s a function in the perl script that parses the html to look for items of interest:

> ```auto
> <span style="color: #0000ff;">sub</span> start {
> 
> ```
> 
> ```auto
> <span style="color: #0000ff;">my</span> ($self, $tag, $attr, $attrseq, $origtext) = @_;
> 
> ```
> 
> ```auto
> # <span style="color: #0000ff;">print</span> out original text
> 
> ```
> 
> ```auto
> <span style="color: #0000ff;">if</span> ($tag eq 'img') {
> 
> ```
> 
> ```auto
> <span style="color: #0000ff;">if</span> ($attr->{'src'}) {
> 
> ```
> 
> ```auto
> $attr->{'src'} = &handle_object($tag, 'src', $attr->{'src'});
> 
> ```
> 
> ```auto
> }
> 
> ```
> 
> ```auto
> }
> 
> ```

Modifying the if ($tag..) conditional to match the table wasn’t that hard at all:

> ```auto
> <span style="color: #0000ff;">sub</span> start {
> 
> ```
> 
> ```auto
> <span style="color: #0000ff;">my</span> ($self, $tag, $attr, $attrseq, $origtext) = @_;
> 
> ```
> 
> ```auto
> # <span style="color: #0000ff;">print</span> out original text
> 
> ```
> 
> ```auto
> <span style="color: #0000ff;">if</span> ($tag eq 'img') {
> 
> ```
> 
> ```auto
> <span style="color: #0000ff;">if</span> ($attr->{'src'}) {
> 
> ```
> 
> ```auto
> $attr->{'src'} = &handle_object($tag, 'src', $attr->{'src'});
> 
> ```
> 
> ```auto
> }
> 
> ```
> 
> ```auto
> }
> 
> ```
> 
> ```auto
> <span style="color: #0000ff;">if</span> ($tag eq 'table') {
> 
> ```
> 
> ```auto
> <span style="color: #0000ff;">if</span> ($attr->{'background'}) {
> 
> ```
> 
> ```auto
> $attr->{'background'} = &handle_object($tag, 'background', $attr->{'background'});
> 
> ```
> 
> ```auto
> }
> 
> ```
> 
> ```auto
> }
> 
> ```

That solved problem number one. The second problem with the script was that it wasn’t asking about partition preference, rather it just dumped the iRule and datagroups into the last partition defined in bigip.conf. This was strange, as the code to handle partitions was in place:

> ```auto
> <span style="color: #0000ff;">my</span> @partitions;
> 
> ```
> 
> ```auto
> <span style="color: #0000ff;">open</span> (CONF, "<span style="color: #8b0000;">/config/bigip.conf</span>") or <span style="color: #0000ff;">die</span> "<span style="color: #8b0000;">Could not read /config/bigip.conf: $!\n</span>";
> 
> ```
> 
> ```auto
> while (<span style="color: #0000ff;">my</span> $line = <CONF>) {
> 
> ```
> 
> ```auto
> <span style="color: #0000ff;">if</span> ($line =~ /^partition (.+) {/) {
> 
> ```
> 
> ```auto
> <span style="color: #0000ff;">push</span> @partitions, $1;
> 
> ```
> 
> ```auto
> }
> 
> ```
> 
> ```auto
> }
> 
> ```

The problem is that the regex is trying to match “partition \<my partition\> {“ and that is (at least in 10.2.1 HF3) no longer in the bigip.conf file. It has been moved to bigip\_sys.conf. Updating the code as shown below solved the issue and now the user is asked for the appropriate partition and the iRule and datagroup gets deployed as expected.

> ```auto
> <span style="color: #0000ff;">my</span> @partitions;
> 
> ```
> 
> ```auto
> <span style="color: #0000ff;">open</span> (CONF, "<span style="color: #8b0000;">/config/bigip_sys.conf</span>") or <span style="color: #0000ff;">die</span> "<span style="color: #8b0000;">Could not read /config/bigip_sys.conf: $!\n</span>";
> 
> ```
> 
> ```auto
> while (<span style="color: #0000ff;">my</span> $line = <CONF>) {
> 
> ```
> 
> ```auto
> <span style="color: #0000ff;">if</span> ($line =~ /^partition (.+) {/) {
> 
> ```
> 
> ```auto
> <span style="color: #0000ff;">push</span> @partitions, $1;
> 
> ```
> 
> ```auto
> }
> 
> ```
> 
> ```auto
> }
> 
> ```

For the full script, head to the iRules wiki entry [LTM Maintenance Page Generator](https://devcentral.f5.com/s/wiki/default.aspx/iRules/LTMMaintenancePageGenerator.html) and grab version 2.2.

_Related Articles_

- [Host that Sorry Page on your BIG-IP!](https://devcentral.f5.com/s/weblogs/jason/archive/2009/05/12/host-that-sorry-page-on-your-big-ip.aspx)
- [about i-rule sorry page configuration - DevCentral - F5 DevCentral …](https://devcentral.f5.com/s/Forums/tabid/53/afv/topic/aff/5/aft/33977/Default.aspx)
- [DevCentral Wiki: Automatic\_maintenance\_page\_\_\_ Sorry\_page\_with\_images](https://devcentral.f5.com/s/wiki/default.aspx/iRules/Automatic_maintenance_page___Sorry_page_with_images.html)
- [DevCentral Wiki: Sorry Page I Rule Generator\_ Perl](https://devcentral.f5.com/s/wiki/default.aspx/iRules/SorryPageIRuleGenerator_Perl.html)
- [DevCentral Wiki: LTM Maintenance Page Generator](https://devcentral.f5.com/s/wiki/default.aspx/iRules/LTMMaintenancePageGenerator.html)
- [DevCentral Wiki: CodeShare](https://devcentral.f5.com/s/wiki/default.aspx/iRules/CodeShare.html)
- [Sorry Page when Severs are down - DevCentral - F5 DevCentral …](https://devcentral.f5.com/s/Default.aspx?tabid=53&aff=16&aft=4642&afv=topic)
- [Site Dwon Page form https virtual server - DevCentral - F5 …](https://devcentral.f5.com/s/Community/GroupDetails/tabid/1082223/aft/26111/asg/39/Default.aspx)

---

<div class="post-metadata">

**Author:** ![JJay\_44003](https://avatars.discourse-cdn.com/v4/letter/j/b19c9b/32.png) [@JJay\_44003](https://community.f5.com/u/JJay_44003)\
**Post date:** [April 9, 2013, 7:50pm UTC](https://community.f5.com/t/hosting-sorry-error-or-maintenance-pages-on-big-ip-ltm-with-irules/67814/2 "2013-04-09T19:50:40Z")

</div>

Is anyone else not seeing the complete article?

---

<div class="post-metadata">

**Author:** ![jrahmDCnew\_4699](https://avatars.discourse-cdn.com/v4/letter/j/c68b51/32.png) [@jrahmDCnew\_4699](https://community.f5.com/u/jrahmDCnew_4699)\
**Post date:** [April 10, 2013, 11:50am UTC](https://community.f5.com/t/hosting-sorry-error-or-maintenance-pages-on-big-ip-ltm-with-irules/67814/3 "2013-04-10T11:50:27Z")

</div>

Hi JJay, this should be fixed now. Also, there is a much cleaner way to do this now with iFiles as of 11.1:

¬†

¬†

[https://devcentral.f5.com/s/articles/v111ndashexternal-file-access-from-irules-via-ifiles](https://devcentral.f5.com/s/articles/v111ndashexternal-file-access-from-irules-via-ifiles)

---

<div class="post-metadata">

**Author:** ![Michael\_Saulter](https://avatars.discourse-cdn.com/v4/letter/m/8e7dd6/32.png) [@Michael\_Saulter](https://community.f5.com/u/Michael_Saulter)\
**Post date:** [August 24, 2017, 10:26pm UTC](https://community.f5.com/t/hosting-sorry-error-or-maintenance-pages-on-big-ip-ltm-with-irules/67814/4 "2017-08-24T22:26:51Z")

</div>

The note at the top of the page references a tech tip on iFiles, but the link is bad. It’s really tough trying to figure out how to properly set up a sorry page when I keep finding out-of-date references and F5 keeps changing how to do it. I wish that at least the ‘recommended path’ was a working link.
