Forum Discussion

Frederic_Zeller's avatar
Frederic_Zeller
Icon for Nimbostratus rankNimbostratus
May 07, 2008

Peristence on X-Forwarded-For

Hi.

 

 

Using Universal Persitence, it's quite easy to persist on a part of the URI. Many example can be found.

 

 

Like :

 

 

when HTTP_REQUEST {

 

persist uie [findstr [HTTP::uri] "user=" 5 "&"]

 

}

 

 

But I'd like to persit on one of the Header field (X-Forwarded-For)

 

 

Cookies can't be used due to multiple URL being used. ( part of the site is http, other part with different URL is https ).

 

 

Source address can't be used due to all client being behind a single proxy

 

 

Has anyone done any persitence on a header field ?

 

 

From the manual, I know it could be done, but how ?

 

 

Any Help would be greatly appreciated ..

 

 

TIA

 

 

Fred

2 Replies

  • Hi Fred,

     

     

    You can replace '[findstr [HTTP::uri] "user-" 5 "&"]' with '[HTTP::header value X-Forwarded-Fo]'r. However, there might be multiple XFF header values in client requests. The HTTP::header command will return the last value. Proxies aren't required to insert an XFF header, so you wouldn't be guaranteed to get a valid value to persist off of. If the proxy in your scenario does insert an XFF header, the HTTP::header command should work for persisting off of the value.

     

     

    Aaron
  • Hi Aaron

     

     

    Just tested that :

     

     

    when HTTP_REQUEST {

     

    persist uie [HTTP::header "X-Forwarded-For"]

     

    log local0. [HTTP::header "X-Forwarded-For"]

     

    }

     

     

    and it works great

     

     

    Guess it will by the proxy responsability to insert the correct header ...

     

     

    THANKS A LOT!