Segue algumas iRules com a utilização do X-Forwarded-For e True-Client-IP:

 

when HTTP_REQUEST {
set True_Client_IP [HTTP::header "True-Client-IP"]
if { $True_Client_IP != "" } {
persist uie $True_Client_IP
#log local0. "[IP::client_addr]:[TCP::client_port]: True-Client-IP: [HTTP::header value True-Client-IP], persist record: [persist lookup uie $True_Client_IP]"
}
}

######################

when HTTP_REQUEST {
set X-Forwarded-For [HTTP::header "X-Forwarded-For"]
set True_Client_IP [HTTP::header "True-Client-IP"]
if { $True_Client_IP != "" } {
log local0. "[IP::client_addr]:[TCP::client_port]: True-Client-IP: [HTTP::header value True-Client-IP]"
}
elseif { $X-Forwarded-For != "" } {
log local0. "[IP::client_addr]:[TCP::client_port]: X-Forwarded-For: [HTTP::header value X-Forwarded-For]"
}
}

######################

when HTTP_REQUEST {
set X_Forwarded_For [HTTP::header "X-Forwarded-For"]
set True_Client_IP [HTTP::header "True-Client-IP"]
if { [HTTP::uri] contains "?" } {
if { $True_Client_IP != "" } {
log local0. "[HTTP::uri]&X-Forwarded-For=[HTTP::header value X-Forwarded-For]&True-Client-IP=[HTTP::header value True-Client-IP]"
HTTP::uri [HTTP::uri]&X-Forwarded-For=[HTTP::header value X-Forwarded-For]&True-Client-IP=[HTTP::header value True-Client-IP]
} else {
log local0. "[HTTP::uri]&X-Forwarded-For=[HTTP::header value X-Forwarded-For]"
HTTP::uri [HTTP::uri]&X-Forwarded-For=[HTTP::header value X-Forwarded-For]
}
}
elseif { $True_Client_IP != "" } {
log local0. "[HTTP::uri]?X-Forwarded-For=[HTTP::header value X-Forwarded-For]&True-Client-IP=[HTTP::header value True-Client-IP]"
HTTP::uri [HTTP::uri]?X-Forwarded-For=[HTTP::header value X-Forwarded-For]&True-Client-IP=[HTTP::header value True-Client-IP]
} else {
log local0. "[HTTP::uri]?X-Forwarded-For=[HTTP::header value X-Forwarded-For]"
HTTP::uri [HTTP::uri]?X-Forwarded-For=[HTTP::header value X-Forwarded-For]
}
}

######################

when HTTP_REQUEST {
set X_Forwarded_For [HTTP::header "X-Forwarded-For"]
set True_Client_IP [HTTP::header "True-Client-IP"]
set new_uri_xff [HTTP::uri]
append new_uri_xff " "
append new_uri_xff X-Forwarded-For=$X_Forwarded_For
set new_uri_tci [HTTP::uri]
append new_uri_tci " "
append new_uri_tci True-Client-IP=$True_Client_IP

if { [HTTP::uri] contains "?" } {
if { $True_Client_IP != "" } {
log local0. "[HTTP::uri]&X-Forwarded-For=$X_Forwarded_For&True-Client-IP=$True_Client_IP"
HTTP::uri [HTTP::uri]&X-Forwarded-For=$X_Forwarded_For&True-Client-IP=$True_Client_IP
} else {
log local0. "[HTTP::uri]&X-Forwarded-For=$X_Forwarded_For"
HTTP::uri [HTTP::uri]&X-Forwarded-For=$X_Forwarded_For
}
}
elseif { $True_Client_IP != "" } {
log local0. "[HTTP::uri]?X-Forwarded-For=$X_Forwarded_For&True-Client-IP=$True_Client_IP"
HTTP::uri [HTTP::uri]?X-Forwarded-For=$X_Forwarded_For&True-Client-IP=$True_Client_IP
} else {
log local0. "[HTTP::uri]?X-Forwarded-For=$X_Forwarded_For"
HTTP::uri [HTTP::uri]?X-Forwarded-For=$X_Forwarded_For
}

 

Comentar


Código de segurança
Atualizar