Converting iRules to NetScaler Policies - X-Forwarded For Header Based Persistence

Converting iRules to NetScaler Policies - X-Forwarded For Header Based Persistence

book

Article ID: CTX206805

calendar_today

Updated On:

Description

Use Case

X-Forwarded-For HTTP header indicates the path where the request came in through and it can have multiple IP addresses as well. You can define persistence based on the value of X-Forwarded-For header received while processing the request on load balancing vserver.

F5 iRules

# Name: persist_xff_uie
			#
			# To be used with UIE Persistence Profile
			#
			# Checks HTTP Request for 'X-Forwarded-For' header and if exists takes the fir
			st 'X-Forwarded-For' IP address as sets as
			# Persist identifier.
			# If the 'X-Forwarded-For' header does not exist then the client IP address is
			set as Persist identifier.
			when HTTP_REQUEST {
			 if {[HTTP::header X-Forwarded-For] != ""} then {
			persist uie [lindex [ split [HTTP::header X-Forwarded-For] ",
			" ] 0]
			 } else {
			persist uie [IP::client_addr]
			}
			}

Source: XFF Universal Persistence iRule.

NetScaler Solution

set lb vserver vip1 -persistencetype RULE -rule 'HTTP.REQ.HEADER("X-Forwarded-For").BEFORE_STR(",")'

NetScaler provides you the ability to define Rule based persistence on a load balancing vserver. The Rule is generated in advance policy infrastructure which has reach to the massive number of expressions which can be used to achieve required results. Here we have specified the HTTP header to be the decision making point for achieving persistence.

 

Issue/Introduction

Converting iRules to NetScaler Policies - X-Forwarded For Header Based Persistence.

Additional Information