Forum Discussion
Pirlo
Nimbostratus
Mar 29, 2010Syntax and Effeciency check
Trying to verify syntax and efficiency for the following rule.
Essentially this is a HTTP vip that needs XFF redirection to a dummy pool if the address matches the data group list.
In the below Irule - Is syntax correct? Is their a more effecient way to process?
when HTTP_REQUEST {
check if client_addr = any in the class
if {[matchclass [HTTP::header "X-Forwarded-For"] equals $::pre_test_address_list]} {
use pool dummypool
} else {
use pool prodpool
}
}
And at the end of the rule do I need the "else use pool prodpool" statement? Or can I leave that out and once the Irule inspection is complete will the LTM proceed with the default pool that the VIP lb's to?
when HTTP_REQUEST {
check if client_addr = any in the class
if {[matchclass [HTTP::header "X-Forwarded-For"] equals $::pre_test_address_list]} {
use pool dummypool
}
- hoolio
Cirrostratus
Hi Blue, - Pirlo
Nimbostratus
Thanks for the link and taking the time to provide feedback. - Pirlo
Nimbostratus
- hoolio
Cirrostratus
You'd need to parse out the IP's from the XFF header value. Can you configure whatever device is inserting the XFF to use a more unique header name? If not, you could use something like this to parse comma separated IPs:when HTTP_REQUEST { Select the prodpool by default pool prodpool Check if XFF header has a value if {[HTTP::header "X-Forwarded-For"] ne ""}{ Some proxies append their XFF value to any existing XFF header. Check if XFF header value contains a comma if {[HTTP::header "X-Forwarded-For"] contains ","}{ Remove any spaces in the string, and then split it into a list on commas set xff [split [string map {" " ""} [HTTP::header value "X-Forwarded-For"]] ","] Get the last comma separated value from the XFF header set xff [lindex $xff [expr {[llength $xff]} - 1]] } else { set xff [HTTP::header "X-Forwarded-For"] } Check if XFF value is in the class if {[matchclass $xff equals $::pre_test_address_list]} { pool dummypool } } }
- Pirlo
Nimbostratus
Aaron - hoolio
Cirrostratus
In testing this with a customer who was using Squid, we saw the most recent IP appended to the XFF header. Are you sure you want to take the first IP in the list?when HTTP_REQUEST { Select the prodpool by default pool prodpool Check if XFF header has a value if {[HTTP::header "X-Forwarded-For"] ne ""}{ Some proxies append their XFF value to any existing XFF header. Check if XFF header value contains a comma if {[HTTP::header "X-Forwarded-For"] contains ","}{ Split the XFF header into a list on commas or spaces and take the first element set xff [lindex [split [HTTP::header value "X-Forwarded-For"] ", "] 0] } else { set xff [HTTP::header "X-Forwarded-For"] } Check if XFF value is in the class if {[matchclass $xff equals $::pre_test_address_list]} { pool dummypool } } }
- Pirlo
Nimbostratus
Aaron - Pirlo
Nimbostratus
Forgot to notate the actual packet flow. In tcpdump the first XFF show to be the actual. - hoolio
Cirrostratus
Ah, that makes sense if it's the Akamai inserted IP you want to use. Thanks for clarifying.
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