Forum Discussion
Sorry Server iRule with iFiles
Hello,
I have been searching the forums, wiki, and web for more information about setting up an iRule that will utilize iFiles to deliver a sorry page using the HTTP::content command. I have found several examples of using iFiles within iRules that have all worked to some extent, however im only able to ever get the HTML file and a single image file to display. Is it possible to display a fully formatted html page with css and multiple images?
Lets say i have an HTML file that links to an external css file /css/style.css. Also in the HTML file there are several links to images such as /images/image1.gif, /images/background.jpg, etc. Is there a way through iRules (and if possible with the use of iFiles) to have the HTML, CSS, and images all display correctly as if it were hosted from a web server? I am able to embed the CSS code in the HTML file and it the css will apply properly, however I would like to use an external css file if possible.
9 Replies
- What_Lies_Bene1
Cirrostratus
Can you provide an example of what you've tried please so I don't just give you more of the same. - Kevin_Stewart
Employee
Assuming you have the iFiles in place (uploaded) and configured (assigned in the GUI), then you'd use a series of URI or path conditionals and the HTTP::respond command. Here's an example:when HTTP_REQUEST { switch [string tolower [HTTP::uri]] { "/images/background.jpg" { HTTP::respond 200 content [ifile get ] "Content-Type" "image/jpeg" } "/css/styles.css" { HTTP::respond 200 content [ifile get ] "Content-Type" "text/css" } "/index.html" { HTTP::respond 200 content [ifile get ] "Content-Type" "text/html" } } }
- Kevin_Stewart
Employee
Two other points I forgot to mention: - pgsmith_120398
Altostratus
I think the underlying issue is i probably dont fully understand whats going on. I think i do but i probably dont...
I started with somthing like this:
https://devcentral.f5.com/tech-tips...via-ifiles
And it worked fine to display the page with a single image file.
I worked my way up to somthing like you suggested before:
https://devcentral.f5.com/tech-tips...via-ifiles
I then took the general idea from that page and simply tried to extend it to more uri's
switch [HTTP::uri] {
"/some-other-image.jpg" { HTTP::respond 200 content [ifile get "some-other-image"] }
Ive also tried this same idea with the use of multiple elseif lines but eventually tried to use switch instead.
- pgsmith_120398
Altostratus
I had also referenced this page and interpreted it as /reset.css = /reset.css in the html file its rendering. With that line of thought I continued to assume that for each /file.ext (which I assume are really URIs) I could just stick in multiple files and as it hit them it would pop them into place in the HTML file it was serving. - What_Lies_Bene1
Cirrostratus
OK, can you post the html file, I think we'll then see where it's going wrong. It doesn't need to be /xxx in the html file. - pgsmith_120398
Altostratus
It really doesnt want me to upload a file so ill jut paste the HTML here:ERPRD is Undergoing Maintenance This page was automatically generated by the software that monitors Enterprise Reporting for scheduled maintenance, upgrades and service interruptions. myUFL system administrators are aware of unplanned service interruptions to Enterprise Reporting when this page is active. After confirmation that Enterprise reporting is actually unavailable due to a non-planned service interruption, an Alert will be posted. Please check the Alerts page for updates. You also may report this incident to the UF Help Desk at 392-HELP or . Thank you. Copyright © 2006, University of Florida, Gainesville, FL 32611; (352) 392-HELP.
- Kevin_Stewart
Employee
If you're using something like the iRule example I listed above, the only other recommendation I'd make is that you use "full path" URLs in your HTML page. Add a logging statement to the beginning of your HTTP_REQUEST event to see what I mean: - pgsmith_120398
Altostratus
I'm really not entirely sure why it wasn't working, however I finally got it working with the following code:when HTTP_REQUEST { if { [active_members [LB::server pool]] < 1} { switch [string tolower [HTTP::uri]] { "/" { HTTP::respond 200 content [ifile get index.html] "Content-Type" "text/html" } "/ufstyle.css" { HTTP::respond 200 content [ifile get ufstyle.css] "Content-Type" "text/css" } "/myuflheaderborder.jpg" { HTTP::respond 200 content [ifile get myuflheaderborder.jpg] "Content-Type" "image/jpeg" } "/myuflheader_bg.jpg" { HTTP::respond 200 content [ifile get myuflheader_bg.jpg] "Content-Type" "image/jpeg" } "/myuflheader.gif" { HTTP::respond 200 content [ifile get myuflheader.gif] "Content-Type" "image/jpeg" } "/myufllogo.gif" { HTTP::respond 200 content [ifile get myufllogo.gif] "Content-Type" "image/jpeg" } "/uflwordmark.gif" { HTTP::respond 200 content [ifile get uflwordmark.gif] "Content-Type" "image/jpeg" } } } }
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