Integration with Squid Proxy Server

In this section

Configuring Dr.Web ICAPD

Configuring Squid

Squid Advanced Settings

Configuring Dr.Web ICAPD

To integrate Dr.Web ICAPD with a Squid HTTP proxy server, you will need to review the current values of parameters in the Dr.Web ICAPD‘s settings section (the [ICAPD] section) and change them if necessary:

In the ListenAddress parameter, specify the address of the network socket (<IP address>:<port>) which will be listened to by Dr.Web ICAPD waiting for connections from an HTTP proxy server (by default, the 127.0.0.1:1344 socket is used).

In the Block* settings, enable or disable categories of websites and threat types that Dr.Web ICAPD should block or allow.

If required, specify the list of websites to be blocked as the value of the BlackList parameter. In the value of the WhiteList parameter you can specify the list of websites that must not be blocked.

Внимание!

The BlackList parameter takes precedence over WhiteList. If a domain is included in the lists for both parameters, it will be blocked.

To configure access to websites in a more detailed way (on the basis of various conditions), you can also edit the scanning rules.

Note

The default values of the UsePreview, Use204 and AllowEarlyResponse parameters in the Dr.Web ICAPD section of the settings allow the component to use the corresponding features of the Internet Content Adaptation Protocol (ICAP) (i.e. allow it to use the ICAP preview mode, to return the 204 status code not only in the ICAP preview mode, and to start sending an “early” response before the entire request has been received from the proxy server). It is recommended that you do not change the default values if no problems with HTTP request processing occur.

After all settings are adjusted, restart Dr.Web for UNIX Internet Gateways with the following command:

# drweb-ctl reload

You can also restart the configuration daemon Dr.Web ConfigD with the following command:

# service drweb-configd restart

Configuring Squid

To enable the interaction between Squid and Dr.Web ICAPD, edit the squid.conf configuration file (usually located in /etc/squid3/) to allow using ICAP. To configure Squid, proceed as follows:

1.Enablе the ICAP in the settings of Squid.

2.Register Dr.Web ICAPD as the ICAP service for Squid.

3.Enable the ICAP preview mode (optionally).

4.Allow transferring the client data (i.e. the IP address and the user name of a user who has passed authentication at the proxy server) for using in the rules of Dr.Web ICAPD (optionally).

5.Enable the support of persistent connections between Dr.Web ICAPD and Squid (optional; though enabling persistent connections is not necessary, it can increase the performance of Squid  working together with Dr.Web ICAPD).

Внимание!

To make Squid check HTTP requests (REQMOD) and HTTP responses (RESPMOD) via the ICAP, add two ICAP services of the corresponding types.

To make Squid use Dr.Web ICAPD as an ICAP service, the address and port specified in icap_service should match the address and port specified in the ListenAddress parameter in the Dr.Web ICAPD‘s settings.

Dr.Web ICAPD will not work with Squid, if the icap_preview_size parameter value is not 0.

The IP-address and the username of the client are sent to Dr.Web ICAPD by Squid in the the ICAP request in X-Client-Username and X-Client-IP headers. The values of these headers must encoded by the methods used in Squid by default. The settings of Squid that affect the encoding methods (icap_client_username_encode and icap_client_username_header headers) should not be modified.

Note

Squid should be built with the support of ICAP (that is, compiled with the --enable-icap-client option). Otherwise, it is not possible to establish the connection between Squid and Dr.Web ICAPD.

Внимание!

For working with the HTTPS protocol Squid should be built with SSL support (that is, compiled with the --with-openssl and --enable-ssl-crtd options). In the settings of Squid SSL bumping should be enabled.

The list of parameters that can be configured depends on the version of the Squid server that you are using (below you can find the description of configuring the following Squid versions: 3.2 (and later), 3.1, and 3.0).
Modify your Squid configuration file according to the given examples.
If the parameters from the examples are commented out, uncomment them. If the required parameters are missing, add them to the Squid configuration file.

Note

Only #1 and #2 steps are obligatory for configuring the interaction between Dr.Web ICAPD and Squid. If other settings, out of those which are mentioned below, are not required, do not add them to the Squid configuration file.

For Squid 3.2 and later versions

#1
icap_enable on
 
#2
icap_service i_req reqmod_precache bypass=0 icap://127.0.0.1:1344/reqmod
icap_service i_res respmod_precache bypass=0 icap://127.0.0.1:1344/respmod
 
adaptation_access i_req allow all
adaptation_access i_res allow all
 
#3
icap_preview_enable on
icap_preview_size 0
 
#4 (In Squid 3.2, the icap_send_client_ip and icap_send_client_username parameters have been renamed)
adaptation_send_client_ip on
adaptation_send_username on
 
#5
icap_persistent_connections on

For Squid 3.1

#1
icap_enable on
 
#2 (In Squid 3.1, the format used to configure a service has been changed and the icap_access parameter has been renamed)
icap_service i_req reqmod_precache bypass=0 icap://127.0.0.1:1344/reqmod
icap_service i_res respmod_precache bypass=0 icap://127.0.0.1:1344/respmod
 
adaptation_access i_req allow all
adaptation_access i_res allow all
 
#3
icap_preview_enable on
icap_preview_size 0
 
#4
icap_send_client_ip on
icap_send_client_username on
 
#5
icap_persistent_connections on

For Squid 3.0

#1
icap_enable on
 
#2
icap_service i_req reqmod_precache 0 icap://127.0.0.1:1344/reqmod
icap_service i_res respmod_precache 0 icap://127.0.0.1:1344/respmod
 
icap_class icapd_class_req i_req
icap_class icapd_class_resp i_res
 
icap_access icapd_class_req allow all
icap_access icapd_class_resp allow all
 
#3
icap_preview_enable on
icap_preview_size 0
 
#4
icap_send_client_ip on
icap_send_client_username on
 
#5
icap_persistent_connections on

Restart Squid after changing the settings.

Advanced Settings for Squid: data size restrictions

If necessary, you can limit the size of data that Squid sends for scanning via the ICAP protocol. To do this, specify in the configuration file the value of the Content-Length header (the specific size in bytes or a regular expression), for example:

acl <name> rep_header Content-Length ^[0-9]{7,}$

(the condition <name> holds, if the header Content-Length in the server response contains a number greater than 999999).

The condition from the example above can be used to allow or deny the scanning of the server response via the ICAP protocol (the word all must be replaced in the connection parameters of Squid by the condition name <name>). The following example shows the settings used to deny the scanning of responses for which the condition <name>holds:

#Squid 3.1 and later versions
adaptation_access i_res deny <name>
 
#Squid 3.0 and later versions
icap_access icapd_class_resp deny <name>

Note

The Content-Length header can be missing in the webserver response. In this case the settings concerning the restrictions of data size will not be applied.

The detailed information on configuring the restrictions of web-traffic in Squid can be found in the official documentation.

Внимание!

After editing the configuration file restart Squid in order than the modified settings take effect.