F5 iRules-----http請求400/500錯誤時,重置

#  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]
	}
}


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章