Hosting Sorry, Error, or Maintenance Pages on BIG-IP LTM with iRules
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 should be the recommended path for sorry pages going forward.
I’ve posted on this before (Host that Sorry Page on your BIG-IP!) 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:
#<table background="genericofflinebackground.gif" align="center" width="1024" height="768" >
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:
sub start {
my ($self, $tag, $attr, $attrseq, $origtext) = @_;
# print out original text
if ($tag eq 'img') {
if ($attr->{'src'}) {
$attr->{'src'} = &handle_object($tag, 'src', $attr->{'src'});}}
Modifying the if ($tag..) conditional to match the table wasn’t that hard at all:
sub start {
my ($self, $tag, $attr, $attrseq, $origtext) = @_;
# print out original text
if ($tag eq 'img') {
if ($attr->{'src'}) {
$attr->{'src'} = &handle_object($tag, 'src', $attr->{'src'});}}if ($tag eq 'table') {
if ($attr->{'background'}) {
$attr->{'background'} = &handle_object($tag, 'background', $attr->{'background'});}}
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:
my @partitions;
open (CONF, "/config/bigip.conf") or die "Could not read /config/bigip.conf: $!\n";while (my $line = <CONF>) {
if ($line =~ /^partition (.+) {/) {
push @partitions, $1;
}}
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.
my @partitions;
open (CONF, "/config/bigip_sys.conf") or die "Could not read /config/bigip_sys.conf: $!\n";while (my $line = <CONF>) {
if ($line =~ /^partition (.+) {/) {
push @partitions, $1;
}}
For the full script, head to the iRules wiki entry LTM Maintenance Page Generator and grab version 2.2.
Related Articles
- Host that Sorry Page on your BIG-IP!
- about i-rule sorry page configuration - DevCentral - F5 DevCentral ...
- DevCentral Wiki: Automatic_maintenance_page___ Sorry_page_with_images
- DevCentral Wiki: Sorry Page I Rule Generator_ Perl
- DevCentral Wiki: LTM Maintenance Page Generator
- DevCentral Wiki: CodeShare
- Sorry Page when Severs are down - DevCentral - F5 DevCentral ...
- Site Dwon Page form https virtual server - DevCentral - F5 ...
- JJay_44003NimbostratusIs anyone else not seeing the complete article?
- jrahmDCnew_4699NimbostratusHi 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 - Michael_SaulterNimbostratus
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.