本帖最后由 俞健 于 2023-8-17 16:48 编辑
F5 iRules 配置翻译
F5配置:
when HTTP_REQUEST {
if { [HTTP::host] equals "hqbz.shufe.edu.cn" } {
HTTP::redirect "https://hqbz.sufe.edu.cn[HTTP::uri]"
}
elseif { [HTTP::uri] starts_with "/hqcy/" } {
if { [ active_members pool_hqcy_rs] < 1 } {
HTTP::respond 200 content [ifile get operation_page.html] "Content-Type" "text/html"
}
else {
pool pool_hqcy_rs
}
}
elseif { [HTTP::uri] starts_with "/place/" } {
if { [ active_members pool_place_rs] < 1 } {
HTTP::respond 200 content [ifile get operation_page.html] "Content-Type" "text/html"
}
else {
pool pool_place_rs
}
}
elseif { [HTTP::uri] starts_with "/saf/" } {
if { [ active_members pool_security_rs] < 1 } {
HTTP::respond 200 content [ifile get operation_page.html] "Content-Type" "text/html"
}
else {
pool pool_security_rs
}
}
elseif { [HTTP::uri] starts_with "/zc/" } {
if { [ active_members pool_gcms_rs ] < 1 } {
HTTP::respond 200 content [ifile get operation_page.html] "Content-Type" "text/html"
}
else {
pool pool_gcms_rs
}
}
elseif { ([HTTP::uri] starts_with "/health/")} {
if { [ active_members pool_healthcare_rs] < 1 } {
HTTP::respond 200 content [ifile get operation_page.html] "Content-Type" "text/html"
}
else {
pool pool_healthcare_rs
}
}
elseif { ([HTTP::uri] starts_with "/mss/")} {
if { [ active_members pool_mss_rs] < 1 } {
HTTP::respond 200 content [ifile get operation_page.html] "Content-Type" "text/html"
}
else {
pool pool_mss_rs
}
}
else {
if { [ active_members pool_newstu_rs] < 1 } {
HTTP::respond 200 content [ifile get operation_page.html] "Content-Type" "text/html"
}
else {
pool pool_newstu_rs
}
}
}
ad ipro配置:
local debug = false
--判断节点池里面的可用节点数量
local function active_members(poolname)
local nodes = nodelist(poolname)
return table.maxn(nodes)
end
local function string_contains(s,p)
local i,j = string.find(s,p)
if i then
return true
else
return false
end
end
event HTTP_REQUEST {
local Host = HTTP.header("Host")
local uri = HTTP.uri()
local reply_page = Object.get(Object.page, "operation_page.html") --资源管理,自定义内容里面定义,200 OK是名称。
local reply_page_1 = Object.get(Object.page, "limit_xiaonei_long_term.html")
local srcip = HTTP.remoteaddr() --获取客户端地址
local ipset = Object.get(Object.address, "sufe_ip_list") --获取管理员地址集
if table.getn(Host) ~= 1 then
HTTP.close()
return
end
Host = Host[1]
if Host == "hqbz.shufe.edu.cn" then
HTTP.redirect("https://hqbz.sufe.edu.cn"..uri)
elseif string_contains(uri,"^/hqcy/") then
if active_members("pool_hqcy_rs") < 1 then
HTTP.respond(reply_page:value())
HTTP.close()
else
pool("pool_hqcy_rs") --pool_www2是节点池名称
end
elseif string_contains(uri,"^/place/") then
if active_members("pool_place_rs") < 1 then
HTTP.respond(reply_page:value())
HTTP.close()
else
pool("pool_place_rs") --pool_www2是节点池名称
end
elseif string_contains(uri,"^/saf/") then
if active_members("pool_security_rs") < 1 then
HTTP.respond(reply_page:value())
HTTP.close()
else
pool("pool_security_rs")
end
elseif string_contains(uri,"^/zc/") then
if active_members("pool_gcms_rs") < 1 then
HTTP.respond(reply_page:value())
HTTP.close()
else
pool("pool_gcms_rs")
end
elseif string_contains(uri,"^/health/") then
if active_members("pool_healthcare_rs") < 1 then
HTTP.respond(reply_page:value())
HTTP.close()
else
pool("pool_healthcare_rs")
end
elseif string_contains(uri,"^/mss/") then
if active_members("pool_mss_rs") < 1 then
HTTP.respond(reply_page:value())
HTTP.close()
else
pool("pool_mss_rs")
end
else
if active_members("pool_newstu_rs") < 1 then
HTTP.respond(reply_page:value())
HTTP.close()
else
pool("pool_newstu_rs")
end
end
} |