# 400/500错误重试
#
#当服务返回400/500状态且当前pool中有存活的node重置http请求,并重新选择pool中的node。
#直到返回正常代码或者轮询完所有存活node后,接受新的http请求
when CLIENT_ACCEPTED {
set retry 0
}
when HTTP_REQUEST {
set http_request [HTTP::request]
}
when HTTP_RESPONSE {
if { ([HTTP::status] starts_with "4") || ([HTTP::status] starts_with "5")} {
incr retry
if { $retry <= [active_members [LB::server pool]] } {
HTTP::retry $http_request
} else {
set retry 0
}
} else {
set retry 0
}
}
when LB_SELECTED {
log local0.info "Run $retry"
if { ($retry > 0) && ($retry <= [active_members [LB::server pool]])} {
LB::reselect pool [LB::server pool]
}
}
转载于:https://blog.51cto.com/centaurs1987/1434118