Forum Discussion
jmas08
Nimbostratus
Jun 18, 2009Help Conditional Maint Irule
Hey Guys,
During maintenance I want to be able to present a maint page to extenal users, while internal users get the actual message form the server for testing purposes. I have this but it is not working.
when HTTP_REQUEST {
sets the timer to return client to host URL
set stime 10
Use the Host header value for the responses if it's set. If not, use the VIP address.
if {[string length [HTTP::host]]}{
set host [HTTP::host]
} else {
set host [IP::local_addr]
}
Check if the URI is /maintenance
switch [HTTP::uri] {
"/maintenance" {
Send an HTTP 200 response with a Javascript meta-refresh pointing to the host using a refresh time
HTTP::respond 200 content \
"Maintenance\
Our Apologies
The application you requested is currently undergoing maintenance. It should be available soon. Please try again later.
" "Content-Type" "text/html"
return
}
}
If the pool_testLB is down, redirect to the maintenance page
if { 0 == [active_members [LB::server pool]] } {
HTTP::redirect "https://$host/maintenance"
return
} else {
return
}
if { (not [ matchclass [IP::client_addr] equals $::Internal-IP ] ) } {
HTTP::redirect "http://$host/maintenance"
return
} else {
return
}
}
Any help is appreciated
Thanks
4 Replies
- The_Bhattman
Nimbostratus
Did you take a look at the following Samples
http://devcentral.f5.com/wiki/default.aspx/iRules/LTMMaintenancePage.html
http://devcentral.f5.com/wiki/default.aspx/iRules/LTMMaintenancePageLite.html
http://devcentral.f5.com/wiki/default.aspx/iRules/LTMMaintenancePageGenerator.html
http://devcentral.f5.com/wiki/default.aspx/iRules/LTMMaintenanceWindow.html
http://devcentral.f5.com/wiki/default.aspx/iRules/LTM_sorry_page_image_when_no_pool_members_available.html
Hope this helps
CB - hoolio
Cirrostratus
You'll run into problems using a variable (or datagroup) name with a hyphen in TCL:
% set ::test-var 10
10
% puts $::test-var
can't read "::test": no such variable
% puts ${::test-var}
10
You could either reference the variable with curly braces or just change it to an underscore.
And if the iRule isn't working, try adding logging to it. This should help you trace which code is actually executing. If you get stuck in your troubleshooting, reply here with details on what isn't working.
You can post your iRule with the [ code ] [/ code ] tags to preserve indentations.
Aaron - jmas08
Nimbostratus
Everything seems to work except detecting the client ip.
Thanks - hoolio
Cirrostratus
If that's the case, can you change the name of the datagroup from Internal-IP to Internal_IP and retest, or change the iRule to reference the datagroup as ${::Internal-IP}? If you've already done this, can you post your updated iRule and the debug logging showing the issue?
Aaron
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