Re: [squid-users] Fecthing Source Ip Address and Invoking a Code

From: Amos Jeffries <squid3_at_treenet.co.nz>
Date: Sun, 08 Sep 2013 02:18:33 +1200

On 8/09/2013 1:38 a.m., Norbert Naveen wrote:
> Sorry let me elaborate this .
> Squid is acting as Transparent Proxy
> User A browses on HTTP say http://abc.com
> When the user requests comes to SQUID .
> I want to Add a additional Header
> HTTP_X_PROFILE=Profile of Customer
>
> How can I add this ? Because based on the IP address , I need to
> Query LDAP / RADIUS / AAA Server and Fetch the User Profile Dynamically
> and add a new header with dynamic fetched value .
>
> Hope this clarifies ..

Okay. Thank you.

You need a external_acl_type helper which recieves the %SRC parameter
and returns the profile details.

In 3.4 (beta) series the annotation feature is a far better way to do
it. The helper returns a custom key=value which is targeted at the headers.
That key-value can be added as the header contents with
add_request_header and the %{key-name}note format option.

Something like this:

   external_acl_type profile %SRC /path/to/helper
   acl profiler external profile
   http_access allow profiler
   request_header_add X-Profile %{profile}note

The helper returns this: OK profile="profile details"\n

Alternatively, you can also do it in 3.3 version where the
add_request_header is present, but that version is stuck with the
logging feature to return detais from the helper. Like so:
    OK log="profile details"\n

and the generic %ea token has to be used in request_header_add:
   request_header_add X-Profile %ea

NP: older versions of Squid lack even the request_header_add feature so
it is not possible to do it without ICAP/eCAP adaptation.

Amos
Received on Sat Sep 07 2013 - 14:18:37 MDT

This archive was generated by hypermail 2.2.0 : Sat Sep 07 2013 - 12:00:03 MDT