Forum Discussion
Sumanta_88744
Jun 11, 2016Cirrus
Universal Persistence with X-forwarder
Hi Experts Can I use Universal persistence using x-forwarder with i-rule? I would have each x-forwarded IP stick to the same back-end pool member. Will this work? Can you please share code? Any ...
- Jul 20, 2016
A formatted version of the "Per VS" rate limiting. You can apply the same irule to all standard VS using UIE persistence.
when RULE_INIT { set static::maxReqs 3; set static::timeout 60; } when HTTP_REQUEST { set vs [URI::basename [virtual]] if { [HTTP::header exists "X-Forwarded-For"] } { set client_IP_addr [getfield [lindex [HTTP::header values "X-Forwarded-For"] 0] "," 1] } else { set client_IP_addr [IP::client_addr] } if { ([HTTP::method] eq "GET") and ([class match [string tolower [HTTP::uri]] ends_with $vs_URI_LIST_TO_LIMIT] ) } { whitelist if { [class match [IP::client_addr] equals $vs_ips_whitelist] }{ return } set getcount [table lookup -notouch "$vs_$client_IP_addr:[HTTP::uri]"] if { $getcount equals "" } { table set "$vs_$client_IP_addr:[HTTP::uri]" "1" $static::timeout $static::timeout } else { if { $getcount < $static::maxReqs } { table incr -notouch "$vs_$client_IP_addr:[HTTP::uri]" } else { reject } } } persist uie $clientip } when HTTP_RESPONSE { persist add uie $clientip }
Yann_Desmarest_
Jun 11, 2016Nacreous
Hi,
You can try this example :
when HTTP_RESPONSE {
persist add uie $clientip
}
when HTTP_REQUEST {
set clientip ""
if { [HTTP::header exists "X-Forwarded-For"] } {
set clientip [HTTP::header "X-Forwarded-For"]
} else {
set clientip [IP::client_addr]
}
persist uie $clientip
}
- Sumanta_88744Jun 21, 2016CirrusHi Yann It appears this doesn't work. Please see error. 01070650:3: FastHTTP profile on virtual server /Common/AFG_BSF_VS can only be used with cookie persistence using insert mode.
- Yann_Desmarest_Jun 21, 2016NacreousHi, this is because you are using fasthttp VS instead of standard VS with http profile
- Sumanta_88744Jun 21, 2016CirrusHi Yann Thanks. It started working after I applied http profile to a standard virtual server. Is One Connect mandatory in this case?
- Yann_Desmarest_Jun 21, 2016NacreousIt's recommended but not mandatory
- Sumanta_88744Jun 22, 2016CirrusHi Yann If I want to log, will this code work? *************************************** when HTTP_RESPONSE { persist add uie $clientip } when HTTP_REQUEST { set clientip "" if { [HTTP::header exists "X-Forwarded-For"] } { set clientip [HTTP::header "X-Forwarded-For"] } else { set clientip [IP::client_addr] } persist uie $clientip log local0. "[IP::client_addr]:[TCP::client_port]: XFF: $xff" }
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects