背景:客户要求需要在停机更新或者系统出故障时进行页面提示【系统维护中】 F5判断系统各节点是否存活 如果全部不存活就跳到指定提示页面 如果至少一台存活就不用跳转到提示页面,正常进行负载。


1.查看html页面引用的图片地址。后面要用到

1
<img src="/test.jpg" alt="">

2.上传图片至F5

导航到 System ›› File Management : iFile List 点击 create 上传
sorry2.png

3.上传网页至F5

导航到 System ›› File Management : iFile List 点击 create 上传

sorry3.png

4.创建图片iFile

​ 导航到 Local Traffic ›› iRules : iFile List ,点击 create,注意Name字段不要使用"." ,尽量使用字符串。

sorry4.png

5.创建 html iFile

​ 导航到 Local Traffic ›› iRules : iFile List ,点击 create,注意Name字段不要使用"." ,尽量使用字符串。

sorry5.png

6.创建iRule

1
2
3
4
5
6
7
8
9
10
11
12
when HTTP_REQUEST {
if { [ active_members test ]==0 } { # test 是 pool名称
switch -glob [string tolower [HTTP::uri]] {
"/test.jpg" { # /test.jpg 是第一步引用的图片资源
HTTP::respond 200 content [ifile get sorrypagejpg ] # 输出图片
}
default {
HTTP::respond 200 content [ifile get sorrypagehtml ] "Content-Type" "text/html" "Cache-Control" "no-cache,must-revalidate" # 输出维护界面
}
}
}
}

7.虚拟服务调用 iRule 并关闭pool member进行测试。

sorry7.png