Forum Discussion
Terrence
Nimbostratus
Jul 09, 2009Writing a generic Irule
A while back I took the LTMMaintenancePage to serve up a maintenance page for the web application. We are about to load balance a second application and would also like to use the maintenance page. Although not fully tested I was able to substitute the Description with the hostname with the following code.
set site_name [HTTP::host]
set index_html [string map "SITE $site_name" ${::template}]
This isn't ideal as something HTTP:host is not the "name" of the application. What I would like to do is have a variable persist upon virtual server similar to the STATS profiles, however I want a string which I could then substitute into the template.
also I currently have three lines
set site_name [HTTP::host]
set index_html [string map "SITE $site_name" ${::template}]
HTTP::respond 200 content $index_html "Content-Type" "text/html"
Can anyone show me the proper brackets to put it all in a one liner?
HTTP::respond 200 content [string map "SITE [HTTP::host]" ${::template}] "Content-Type" "text/html"
I unfortunately do not have a test box to test on(its currently in paperwork somewhere), but we have a maintenance window this weekend which I can have some time to do some testing.
References:
http://devcentral.f5.com/wiki/default.aspx/iRules/LTMMaintenancePage.html
- hoolio
Cirrostratus
What you've got should be equivalent: - Terrence
Nimbostratus
What I wanted is a way to have a variable available to all servers applied to a particular VIP, with a scope of that VIP. I started throwing together a code where I can use a generic maintenance page irule, although it is not how I orginally set out to accomplish it.class maint_home_css { type string filename "/var/class/maint.home.css.class" } class maint_index_html { type string filename "/var/class/maint.index.html.class" } class maint_logo_gif { type string filename "/var/class/maint.logo.gif.class" } class maint_site_desc { "lists.aa.net" := "Company's Support Mailing lists" "cct.aa.net" := "CAS - Central Authentication(Dev)" "login.aa.net" := "Central Authentication Service(CAS)" "forums.aa.net" := "Company's Support Forums" } rule webserver { when HTTP_REQUEST { If the http_pool is down, redirect to the maintenance page if { [active_members webct-pool] < 1 } { switch [HTTP::uri] { "/" - "/index.html" { set index_html [b64decode [string map "SITE [class lookup [HTTP::host] maint_site_desc]" [class element 0 maint_index_html]]] HTTP::respond 200 content $index_html "Content-Type" "text/html" } "/logo.gif" { HTTP::respond 200 content [b64decode [lindex $::maint_logo_gif 0]] "Content-Type" "image/gif" } "/home.css" { HTTP::respond 200 content [lindex $::maint_home_css 0] "Content-Type" "text/css" } "default" { HTTP::respond 301 "Location" "/" } } return } } }
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