Forum Discussion
lunitic_56137
Jul 02, 2012Nimbostratus
Maintenance/sorry page with image on v11.1
I have written maintenance pages in the past with ease. The examples Devcentral were very helpful. The problem with creating one now that I find are the "iFiles" introduction in v11.
The way we used to do it is this:
"when HTTP_REQUEST {
Check active members of pool, if 0 respond with Apology Page.
if { [active_members your_pool] == 0 } {
HTTP::respond 200 content {
Apology Page
We are sorry, but the site you are looking for is temporarily out of service
If you feel you have reached this page in error, please try again.
}
}
}
"
To get a logo in the html, we just had to put it in a path and call it out. With iFiles, I understand, we call it with the "HTTP::response" 200 command. Since I already use it to create the html page, it seems I cant use it again for the logo picture call. I created this iRule for the new sorry page:
"when HTTP_REQUEST {
Set global variables.
set VSPool [LB::server pool]
set logo [ifile get logo.png]
Check for active members in the associated pool and respond with html content when the pool members are less than 1
if { [active_members $VSPool] < 1 } {
HTTP::respond 200 content {
Maintenance Page
The page you are trying to access our web site, we are currently unavailable due to maintenance. We apologize for the inconvenience. If you need to reach us, please call 1-800-123-1234 or email . If you are a customer and need to access our Support Web site, please go to http://support.domain.com.
}
}
}"
I have tried to call the "$logo" variable inside of the html as well as the "[ifile get logo.png]" command but it doesnt work. I even tried to add an "IF" statement before the html "IF" but all it does then is show the logo, no text.
ideas?
TIA
- nitass_89166Noctilucentthis is mine.
root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm virtual bar ltm virtual bar { destination 172.28.19.252:http ip-protocol tcp mask 255.255.255.255 pool foo profiles { http { } tcp { } } rules { myrule } snat automap vlans-disabled } root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm pool foo ltm pool foo { members { 200.200.200.101:http { address 200.200.200.101 session monitor-enabled state down } } monitor fake } root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm rule myrule ltm rule myrule { when HTTP_REQUEST { if {[active_members [LB::server pool]] < 1} { switch [HTTP::uri] { "/" { HTTP::respond 200 content [ifile get "index"] } "/f5-logo.jpg" { HTTP::respond 200 content [ifile get "logo"] } } } } } root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm ifile index ltm ifile index { file-name index } root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm ifile logo ltm ifile logo { file-name logo } root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list sys file ifile index sys file ifile index { checksum SHA1:73:dca073b6657b15686c98bf5c9d5fecefec461453 create-time 2012-07-02:21:29:42 created-by admin last-update-time 2012-07-02:21:52:02 mode 33188 revision 2 size 73 updated-by admin } root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list sys file ifile logo sys file ifile logo { checksum SHA1:5960:613133dcd34ea47070f38eca13b414920ade82b8 create-time 2012-07-02:21:26:25 created-by admin last-update-time 2012-07-02:21:26:25 mode 33188 revision 1 size 5960 updated-by admin }
- Jason_AdamsEmployeeI really like the fact that you are using a switch statement && iFiles to host all of the content on your maintenance page. Great stuff.
- lunitic_56137NimbostratusShoot,
- nitassEmployeethis is mine.
root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm virtual bar ltm virtual bar { destination 172.28.19.252:http ip-protocol tcp mask 255.255.255.255 pool foo profiles { http { } tcp { } } rules { myrule } snat automap vlans-disabled } root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm pool foo ltm pool foo { members { 200.200.200.101:http { address 200.200.200.101 session monitor-enabled state down } } monitor fake } root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm rule myrule ltm rule myrule { when HTTP_REQUEST { if {[active_members [LB::server pool]] < 1} { switch [HTTP::uri] { "/" { HTTP::respond 200 content [ifile get "index"] } "/f5-logo.jpg" { HTTP::respond 200 content [ifile get "logo"] } } } } } root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm ifile index ltm ifile index { file-name index } root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm ifile logo ltm ifile logo { file-name logo } root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list sys file ifile index sys file ifile index { checksum SHA1:73:dca073b6657b15686c98bf5c9d5fecefec461453 create-time 2012-07-02:21:29:42 created-by admin last-update-time 2012-07-02:21:52:02 mode 33188 revision 2 size 73 updated-by admin } root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list sys file ifile logo sys file ifile logo { checksum SHA1:5960:613133dcd34ea47070f38eca13b414920ade82b8 create-time 2012-07-02:21:26:25 created-by admin last-update-time 2012-07-02:21:26:25 mode 33188 revision 1 size 5960 updated-by admin }
- Jason_AdamsEmployeeI really like the fact that you are using a switch statement && iFiles to host all of the content on your maintenance page. Great stuff.
- lunitic_56137NimbostratusSo I take it the iFile for index is the html code and there is an href for /f5-logo.jpg?
- nitassEmployee
yes, index is html and logo is jpeg.
- lunitic_56137Nimbostratusok. Thanks. I will try that.
- lunitic_56137Nimbostratusok, I set up the html page and it only shows the html code
- El_JefeNimbostratusMake sure you import the iFile correctly - have a look at this - https://devcentral.f5.com/Tutorials/TechTips/tabid/63/articleType/ArticleView/articleId/1086514/v111ndashExternal-File-Access-from-iRules-via-iFiles.aspx
- lunitic_56137NimbostratusI went according to that posting. When I go to the VS, I see the html. I am wondering what I could have missed. I imported the files, then made the iFile reference in the iFiles section under iRules. I see the code as it is in the index_html file. It just doesn't interpret as html code. it displays as text. I have done this before and it has worked fine.
- lunitic_56137NimbostratusNevermind. Seems to be a problem with Firefox. IE seems to work just fine
Recent Discussions
Related Content
Â
DevCentral Quicklinks
* 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
Discover DevCentral Connects