Forum Discussion
Maintenance Page using multiple ifiles
Hi,
I am trying to set up an irule maintenance page using ifiles but am having difficulty getting the images to work. I need to have different pages for different domains e.g
when LB_FAILED { if { [string tolower [HTTP::host]] contains "tesdomain1.ie" } { HTTP::respond 200 content [ifile get cz-index.html] } elseif { ( [string tolower [HTTP::host]] contains "testdoamin2.ie" ) } { HTTP::respond 200 content [ifile get at-ie-index.html] } } This works but the images referenced in the html and created as ifiles are not seen. Have played around with the irule but no joy
If I use the following irule for all domains it works, but I need to show different, so not quite sure how to proceed?
when HTTP_REQUEST { if {[active_members [LB::server pool]] < 1} { switch [HTTP::uri] { "/" { HTTP::respond 200 content [ifile get "at-test-index.html"] } "/at-caravans-logo.png" { HTTP::respond 200 content [ifile get "at-test-logo.png"] } } } }
- THiNimbostratus
The images cause a new http get request, therefore you do not see them in the response created by the LB_FAILED event.
Either catch the image request and respond separately in HTTP_REQUEST event...
set css xxx-css set logo xxx-logo ... switch [HTTP::uri] { "/xxx.css" { HTTP::respond 200 content [ifile get $css] "Content-Type" "text/css; charset=utf-8" } "/xxx.png" { HTTP::respond 200 content [ifile get $logo] "Content-Type" "image/png" } }
Also try adding Content-Type image/png header. The code works with us (11.5.1 sw). We put the iFile names into variables as they were needed elsewhere in the iRule logic.
... or you do it inline in the LB_FAILED by b64 encoding into response html, something like:
set img [b64encode [ifile get $logo]] ...
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