Forum Discussion
Serving images via iRules from v11.1
Perhaps a better title would be "What Am I Missing?"
I wanted to implement a Maintenance page for use when we have servers down for work. We're using BigIP v11.1. The first thing I found when searching the web was an article on RESDEV-OPS (http://www.resdevops.com/2013/01/25/hosting-maintenancesorry-site-from-a-f5-nlb/), which was essentially a version of this DevCentral article: https://devcentral.f5.com/wiki/iRules.LTMMaintenancePage.ashx. The author of the RESDEV-OPS piece mentioned some new capability in v11.1 over v10.x using iFiles, and since I didn't have his need to make it work on v10, I looked into that.
This lead me to Jason Rahm's DevCentral very nice article on the subject (https://devcentral.f5.com/articles/v111-ndashexternal-file-access-from-irules-via-ifiles) which outlined the use of iFiles for this purpose. This seemed a lot simpler, so I worked up a similar solution for my page. My maintenance page is quite simple; it just displays some text and an image. Here is the iRule:
when HTTP_REQUEST {
set VSPool [LB::server pool]
if { [active_members $VSPool] < 1 } {
log local0. "Client [IP::client_addr] requested [HTTP::uri] no active nodes available..."
if { [HTTP::uri] eq "/x_logo.png" } {
HTTP::respond 200 content [ifile get maint_logo_img] "Content-Type" "image/png"
} else {
HTTP::respond 200 content "
Please Excuse Our Absence
PeopleSoft at the Org X is currently down for maintenance.
We promise to be back online soon, though.
For more information, see our .
Thank you for your patience!
"
}
}
}
Great so far. The image was uploaded to the F5 using the procedure in Jason Rahm's article, and is referenced as the iFile maint_logo_image. After attaching this to a test virtual server, and turning off the pool members attached to it, indeed the page comes up. All except for the image. The effect is different for different browsers. Chrome will try to show the image. If you keep refreshing, the image will show transiently as the page loads. Many times it will show a blurred or highly pixellated version of the image if I go to the /x_logo.png URL. Firefox usually will not show the image under any circumstances, but will transiently show an error message saying "there were errors in the image and it couldn't be displayed". IE actually will attempt to render the image, and gets about 30% of it. So in IE, I see a truncated image, or a highly pixellated image. Here's an example from IE:
This leads me to believe that there's something wrong with the image or with the way I uploaded it to the F5. I even got so desperate that I took F5's advice and redid the way I presented the images according to the 10.x article, base64-encoding the image into a class datagroup. No dice. I got similar results. I have tried other images, with similar results as well.
It seems pretty obvious that I'm doing something wrong here, but I can't figure out what it is from the sources that I have looked at. Has anyone out there had similar issues, or does anyone have an idea as to what might be wrong?
- uniAltostratus
Your rule looks fine to me (except for the html content being rendered by the forum software)
Check /var/log/ltm for any messages at the time you access the file. I would look at capturing at your client and on the appliance, to see what is going on.
- John_Alam_45640Historic F5 Account
Try specifying the content type.
- uniAltostratusHe does
- John_Alam_45640Historic F5 Account
Yes, sorry.
- Kevin_StewartEmployee
I'd say your iRule is likely correct given that you're seeing the image, if only badly. If the URL in the page is correct, and you can see the F5 serving the image, then it's a fair bet there's something wrong with the image. What happens if you put the HTML file and image on a web server and try to access directly?
- Mark_Young_1375Nimbostratus
Thanks to everyone who answered here.
The problem has been resolved. Uni's suggestion of looking at the logs proved to be key. I guess I should have realized that they would be in /var/log/ltm. Turns out the problem was due to my not removing (or modifying) a pre-existing redirection iRule that I had attached to the virtual server. It's a little counterintuitive (for me), but what was happening is since I stacked the Maintenance page iRule in front of the existing redirection, the maintenance page code was invoked when all pool members were down - this is why under some circumstances I could see the image sort of "fly by". then the next iRule attempted to redirect to URIs that weren't working (because there were no active pool members), which messed things up. After removing the redirection iRule, the maintenance page comes up. How stupid of me. Thank you, Uni, for pointing me to the log location. Thank you everyone, for answering so promptly!
- John_Alam_45640Historic F5 Account
Thanks for posting back. We've all learned a good number of lessons the hard way.
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