Install Squid Windows

21
Part-1 There are various software that implement a proxy server, some commercial and some free stuff. In this guide we will see how to implement a proxy server in a Windows environment is fully integrated into Active Directory at no cost. The product concerned is Squid http://www.squid-cache.org/ , originally developed for the Linux porting is also available on the Windows platform. Integration with Active Directory, you can if we install on a machine both Linux and Windows, on Linux configuration for authentication in AD is slightly more complex than in the Windows environment. Squid can be installed on any machine of our network not necessarily with two network adapters, in which case must do also from gateway. First we must download Squid from http://squid.acmeconsulting.it/index.html site, follow the signs for Squid 2.7 for Windows-> Squid Download Page-> mirror mirror 1/ 2-> and here and get the latest version Stable, at the moment is the 2.7. STABLE8. Once the download unpack the .zip file in the path c:\squid. Copy these three files in the path c:\squid\etc: * squid.conf.default == > squid.conf * mime.conf.default == > mime file * cachemgr.conf.default == > cachemgr. conf Open the squid.conf and making some changes required for the first time: * Section OPTIONS FOR AUTHENTICATION o Remove the comment on these three rows and we complete the first so that you have: auth_param ntlm program c:/squid/libexec/mswin_ntlm_auth .exe auth_param ntlm children 5 auth_param ntlm keep_alive on

Transcript of Install Squid Windows

Page 1: Install Squid Windows

Part-1

There are various software that implement a proxy server, some commercial and some free stuff. In this guide we will see how to implement a proxy server in a Windows environment is fully integrated into Active Directory at no cost.

The product concerned is Squid

http://www.squid-cache.org/

, originally developed for the Linux porting is also available on the Windows platform.

Integration with Active Directory, you can if we install on a machine both Linux and Windows, on Linux configuration for authentication in AD is slightly more complex than in the Windows environment.

Squid can be installed on any machine of our network not necessarily with two network adapters, in which case must do also from gateway.

First we must download Squid from

http://squid.acmeconsulting.it/index.html

site, follow the signs for Squid 2.7 for Windows-> Squid Download Page-> mirror mirror 1/ 2-> and here and get the latest version Stable, at the moment is the 2.7. STABLE8.

Once the download unpack the .zip file in the path c:\squid. Copy these three files in the path c:\squid\etc:

        * squid.conf.default == > squid.conf        * mime.conf.default == > mime file        * cachemgr.conf.default == > cachemgr. conf

Open the squid.conf and making some changes required for the first time:

    * Section OPTIONS FOR AUTHENTICATION          o Remove the comment on these three rows and we complete the first so that you have:

                        auth_param ntlm program c:/squid/libexec/mswin_ntlm_auth .exe                        auth_param ntlm children 5                        auth_param ntlm keep_alive on

            These parameters indicate to squid to use authentication NTLM, to use the program and mswin_ntlm_auth. xe to authenticate and use 5 concurrent processes for authentication.    * ACCESS CONTROLS Section          o Default Squid grants access from local networks that have private ip addresses of 3 standard classes, if our network does not fall into these we must add it to these 3 lines:

Page 2: Install Squid Windows

                        acl localnet src 10.0.0.0/8 # RFC1918 possible internal network                        acl localnet src 172.16.0.0/12 # RFC1918 possible internal network                        acl localnet src 192.168.0.0/16 # RFC1918 possible internal network

          o In the basic configuration Squid grants access only to the following ports:

                        acl SSL_ports port 443                        acl Safe_ports port 80 # http                        acl Safe_ports port 21 # ftp                        acl Safe_ports port 443 # https                        acl Safe_ports port 70 # gopher                        acl Safe_ports port 210 # wais                        acl Safe_ports port 1025-65535 # unregistered ports                        acl Safe_ports port 280 # http-mgmt                        acl Safe_ports port 488 # gss-http                        acl Safe_ports port 591 # filemaker                        acl Safe_ports port 777 # multiling http

         Also here if we have other needs we must add the ports you want to be reached.          o Immediately after the last we must insert an ACL to verify authentication in Active Directory:

                        acl Authenticated using proxy_auth ACL REQUIRED

            and set an access rule that denies all unauthenticated sessions:

                        http_access deny!Authenticated

                        be inserted immediately after the line:

                        # INSERT YOUR OWN RULE (S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS

    * Section DISK CACHE OPTIONS          o In this section we have to set the configuration parameters of the disk cache, to do this, remove the comment line:

                        cache_dir ufs c:/squid/var/cache 100 16 256

            and edit the parameters according to our needs.            Taking into account that the three parameters have this meaning:            100 = maximum size in MB of disk cache

Page 3: Install Squid Windows

            16 = number of subdirectories (1st level)            256 = number of subdirectory of 2nd level            Initially we can leave the default these 3 parameters.

    * LOGFILE OPTIONS Section

          o In this section we define the location and the type of access log file that is generated by Squid.            The path is defined by the following directive:

                        access_log c:/squid/var/logs/squid access.log

            While the type is defined by the line:

                        logformat squid%0% ts.3tu% 6tr% a% Ss/>% < st 03Hs%% rm% ru% a% Sh/% <% mt

            in this case we define a log format called squid and use it in the command access_log.

    * ADMINISTRATIVE PARAMETERS Section

          o In case of failure or to access an unauthorized site Squid displays a page with details including an e-mal address of the system administrator. In this regard we can change this address by using the following directive:

                        cache_mgr <indirizzo_email>

    * ERROR PAGE OPTIONS Section

          o The last parameter to change the language in which you want to display the error pages, to achieve this, we use this directive:

                        error_directory c:/squid/share/errors/English

            where instead of English we insert the name of the directory that reflects the language that we use inside the folder c:/squid/share/and rrors, in the case of English we:

                        error_directory c:/squid/share/errors/Italian

At this point, the basic configuration Squid is finished and we can send him running for the first time. Open a dos directory, find the white flashing c:\squid\sbin and launch the command:

Page 4: Install Squid Windows

                                  squid-z

in order to create the cache directory. If we have not made mistakes in the configuration file you should see something like:

C:\squid\sbin>squid -z2010/04/24 11:33:24| Creating Swap Directories

We suggest that the creation of the directory is successful, otherwise we will see something like:

C:\squid\sbin>squid -z2010/04/24 11:41:28| parseConfigFile: squid.conf:4257 unrecognized: 'error_directoryxxx'2010/04/24 11:41:28| Creating Swap Directories

in which case we have committed some syntax error. (In this case was wanted!!).

    NOTE: If we install squid in the default directory c:\squid we should never specify the location of the configuration file, if instead we use a different path is necessaroio change all references in the squid.conf file and use the parameter -f configfile every time I launch the commandsquid.exe.

Now we can install Squid as a service and start to test it. To do this, launch the command:

C:\squid\sbin>squid -iRegistry stored HKLM\SOFTWARE\GNU\Squid\2.6\Squid\ConfigFile value c:/squid/etc/squid.confSquid Cache version 2.7.STABLE8 for i686-pc-winntinstalled successfully as Squid Windows System Service.To run, start it from the Services Applet of Control Panel.Don't forget to edit squid.conf before starting it.

If all is successful you will create the service Squid. If we want to call it differently, we need to add the parameter -n servicename. Once you have created the service we need to start it with the command:

net start Squid

and we will get output like:

Page 5: Install Squid Windows

The Squid service is starting.The Squid service was started successfully.

We verify that Squid is actually listening via the command:

C:\squid\sbin > netstat -na | findstr :31280.0.0.0 0.0.0.0: 3128 TCP: 0 LISTENING

As you can see clearly squid is listening on the default port 3128.

Open Internet Explorer on a client and to configure the proxy settings using the menu Tools > Internet Options-> Connections-> LAN Settingsand set the proxy server as shown in Figure:

replacing the address and port of the server with those of our configuration.

Let's go back to the browser and try to reach a site any, if everything works you should see the page without any problem.

To verify the actual use of the proxy, we can use one of several test online type

http://www.lagado.com/proxy-test

or check the file access.log in the folder C:\squid\var\logs.

If you see a window like this:

Page 6: Install Squid Windows

We ask for your login credentials means that the proxy is working but there is some problem with NTLM authentication. In this case we change the LAN Manager authentication level in value:

Send LM and NTLM – use NTLMv2 session security if negotiated

For simplicity we can change the Default Domain Policy so you want to configure all machines in the domain. The setting is located in the key:

Computer Configuration-> Policies-> Windows Settings-> Security Settings-> Local Policies-> Security Options-> Network security: LAN Manager authentication level

Once change expect the policy is applied or forziamola with the command GPUDATE/force, then try again and if everything went well this time the request for username and password should appear.

With the procedures specified so far according to Squid configuration has finished, access is granted to all for any site and a log is generated for each login.

In next part we will see some parameters for optimization of Squid and how to configure the proxy settings in the browser automatically 

Part-2

In the first part of the guide we saw how to configure the service squid, we will see now how to configure automatic clients to use it and some optimizations to the service itself.

Client configuration

Page 7: Install Squid Windows

The easiest way, but more laborious, to configure clients to modify by hand your Internet Explorer settings to use the proxy server that we configured. The same operation can be automated using the GPO (Group Policy Object).

Edit the Default Domain Policy or any policy to configure the proxy settings in this way:

that were found in the path User Configuration – Windows – > Settings > IEM – > Connection. This configuration works well but has the disadvantage of set the proxy in the client permanently, could then arise problems using them in other networks where there is a proxy or still exists but with different access parameters.

To resolve this problem, we can use the automatic configuration feature of Internet Explorer. In practice through GPO to configure Internet Explorer to use the automatic configuration and then we configure the DNS and a configuration file to ensure that the proxy parameters are configured in each session.

In this case the policy you want to change is the automatic configuration of browsers that are always in the same location User Configuration – Windows – > Settings > IEM – > connection.

Page 8: Install Squid Windows

Once the policy is applied, or we have forced the application with the command gpupdate/force, in LAN settings of the tab Connections ofInternet Options should see the flags automatically detect settings flagged.

So far we have configured Internet Explorer to use the automatic settings, now we must create the file with the settings and ensure that it can be found. Create a text file with:

        function FindProxyForURL( url, host )        {        if( isPlainHostName( host ) || // se nessun dominio viene specificato        dnsDomainIs( host, ".dominio.local") ||        isInNet( host, "192.168.1.0", "255.255.255.0" ) ||        )        return "DIRECT"; // Non si usa alcun proxy        else        return "PROXY 192.168.1.10:3128"        }

where .local domain and 192.168.1.0/255.255.255.0 put your data that can contain multiple lines added with the operator || (or). Save the file with the name WPAD.dat any location that is accessible via the web, for example, we can put in the root of a server with IIS so that you can achieve with http://192.168.1.10/wpad.dat or http://srv-sbs/wpad.dat.

If you try one of the addresses above and get an error like:

Page 9: Install Squid Windows

It is likely that you are using IIS and the .dat extension is configured in the list of MIME Extensions. To do this, open the IIS management console and in server properties, click the button MIME types and add the extension .dat so configured:

Page 10: Install Squid Windows

and restart IIS. You should be able to see the WPAD.dat file within Internet Explorer.

Now that we have created the file we need to configure the system so it is read automatically from Internet Explorer. To do this we can exploit the DNS and/or DHCP.

Let's see now how to configure DNS for DHCP service, please refer to this article on TechNet:

http://technet.microsoft.com/en-us/library/cc713344.aspx

Open the DNS management console and in the forward lookup zone for your domain, create a CNAME record called wpad that points to the server where you saved the WPAD.dat file. Then make sure that everything works by opening an Internet Explorer window and typing:

http://wpad.dominio.local/wpad.dat

If everything is configured correctly you should see the contents of the WPAD.dat file.

If you cannot resolve the name wpad.dominio.local make sure that the name wpad is not included in the the Global Query Block List: 

http://www.indented.co.uk/index.php/2009/05/21/windows-2003-dns-global-query-block-list/

Now we just have to open Internet Explorer and verify the actual use of the proxy server.

Using automatic configuration with the WPAD.dat file turns out to be very handy if you often need to access the internet through the proxy, portable external to your network.

Log configuration

The default format of proxy access log, as well as others, are useful in the case are to be interpreted by external software. If you want to a format that is more understandable for us humans and easily importable in Excel you can create a new type with these specs:

        logformat my "%>a","%ul","%rm %ru HTTP/%rv","%Hs","%<st","%Ss:%Sh","%tl"

and then set up squid for use with the line:

        access_log c:/squid/var/logs/access.log my

With time you will notice that the log files, especially the access.log file will tend to grow significantly, we can then use the works logrotate of squid to create several files at

Page 11: Install Squid Windows

certain times.

The easiest way is to schedule the command:

squid –n squid –k rotate

Maybe once a month so you can store the log file.

Whenever we execute the command files will be renamed according the following scheme:

        access.log.x – access.log.x + 1 >        cache.log.x – cache.log.x + 1 >        store.log.x – store.log.x + 1 >        …        access.log 2.0 – > 1 access.log.        log cache – cache >. 1        store .log 2.0 – > store .log. 1        access.log – > access.log. 0        log cache – cache >. 0        store log – > store .log. 0

The number of file versions that are maintained by squid depends on the value set for the parameter:

        logfile_rotate 60

In this case will be preserved 60 copies of logs, which rotated each month if correspond to 5 years.

Various Configurations

Default squid sends to the real site visited the address of your machine then we will see private:

        X-Forwarded-For: 192.1.2.3

If you want to hide your private IP you have to edit this parameter in the following way:

        forwarded_for off

Configuring permissions

If you've come this far you will have a fully functioning system where all users in Active

Page 12: Install Squid Windows

Directory can access any site, and all those who are not authenticated do not have access to the outside.

Often arises the need to allow access to some web sites without having to authenticate and to block more or less selective access sites, for example we may want to allow downloading Windows updates or virus definitions on all PCs.

To do this we must first create a text file with the list of free sites:

        windowsupdate.com.        . windowsupdate.Microsoft.com        update.microsoft.com        your

and salviamolo as C:\squid\etc\URL_consentiti.txt, then edit the squid configuration file to use this newly created list.

At the end of the ACL directives we add this line:

        acl link-consentiti url_regex "c:/squid/etc/URL_consentiti.txt

in order to create an Access Control List URL_consentiti call that contains all URLs in the file, then add the line:

        http_access allow URL_consentiti

just before the one that denies access to unauthenticated users (http_access deny!Authenticated).

Once restarted Squid verified that links present in the file are also made available without authentication.

The same way we can define a list of users who have unlimited access to the web. Create a file containing users with the domain:

        domain\user1        dominio\utente2        …        dominio\utenten

and salviamolo as C:\squid\etc\Utenti_illimitati.txt and edit the squid configuration file for loading this ACL using the line:

        acl Utenti_illimitati proxy_auth "c:/squid/etc/Utenti_illimitati.txt"

Page 13: Install Squid Windows

Finally, we allow access to this ACL:

        http_access allow Utenti_illimitati

immediately after the previously inserted directive http_access.

Now we can create a list of sites that will be blocked for all users except for those listed Utenti_illimitati. Let's create a new text file calledC:\squid\etc\URL_bloccati.txt that will contain the list of sites like:

        . facebook.com        youtube.com

We create the usual ACL with the line:

        acl URL_bloccati url_regex "c:/squid/etc/URL_bloccati.txt"

and finally we deny access to this ACL with the line:

        http_access deny URL_bloccati

be inserted immediately after the previously inserted directive http_access.

For each file change squid.conf goes restart Squid service.

If you want to create lists of addresses allowed per user, you must create a file containing one or more users and a file containing links allowed for that user (s).Then create two ACLS, one for users and one for the link:

        acl Utente1 proxy_auth "c:/squid/etc/Utente1.txt"        acl Utente1_Link url_regex "c:/squid/etc/Utente1_Link.txt"

and placed within the same directive in order to be satisfied both:

        http_access allow Utente1 Utente1_Link

Notes

Whether to install Squid on a machine where you installed the DNS most likely after a reboot you will find yourself in the situation that Squid fails to start because some ports are down state used by the DNS service.

Page 14: Install Squid Windows

The default ports of Squid, not all are enabled:

        * 3128 TCP        * 3130 TCP        * 3135 TCP        * 4827 TCP

We must therefore provide to set a parameter in the Windows Registry for Reserved configure them as so that DNS does not use them.

the procedure is very simple and is reflected in the article: 

How to reserve a range of ephemeral ports on a computer that is running Windows Server 2003 or Windows 2000 Server

http://support.microsoft.com/kb/812873/en-us

   1. Start Registry editor (Regedit.exe).

   1. Locate and select the following registry subkey KEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Service s\Tcpip\Parameters:   2. Choose new Edit menu, and then multi-string value.   3. , Right-click the new value, click Rename to, type ReservedPorts and then press ENTER.   4. Double-click the ReservedPorts value, type the range of ports that you want to reserve, and then click OK on.      Note You must type the range of ports in the following format:      xxxx-yyyy      To specify a single port, use the same value x and of y. For example, to specify port 4000, type 4000-4000.      Warning If you specify ports continue separately and if a port is reserved and is not used properly the next door is not confidential and is used.   5. Click OK on. 

Page 15: Install Squid Windows

Quản lý truy cập internet với Squid proxy

Hầu hết các tổ chức, doanh nghiệp cỡ vừa và nhỏ đều có nhu cầu giới hạn truy cập internet chỉ cho 1 số người dùng và tiết kiệm băng thông internet. Một trong những giải pháp mở, miễn phí và rất hiệu quả hiện nay là sử dụng Squid trên nền Linux làm 1 Proxy Server.

Người sử dụng cấu hình trình duyệt web của họ để kết nối internet thông qua Squid Server thay vì kết nối trực tiếp. Khi 1 yêu cầu duyệt web đến từ người dùng, Squid sẽ kiểm tra trong cache của nó thông tin về trang web đó. Nếu tìm thấy, nó sẽ gửi trang web đó về trình duyệt người dùng mà không cần kết nối vào internet. Nếu không thấy, nó bắt đầu kết nối vào địa chỉ trang đó và tải về rồi chuyển tiếp cho trình duyệt.

Điều này làm giảm đáng kể lượng dữ liệu tải về từ internet. Một lợi ích khác nữa là chúng ta có thể cấu hình firewall để chỉ cho phép kết nối web thông qua Squid, còn lại tất cả các máy trong mạng nội bộ đều không được phép kết nối trực tiếp internet. Do đó, ta có thể kiểm soát truy cập internet của người dùng thông qua cơ chế xác thực User/Password.

Download và Cài đặt Squid Package

Hiện nay, hầu hết các phần mềm trên Linux đều phổ biến ở 2 dạng đã được biên dịch sẵn là RPM (dành cho distro Redhat Linux) và DEB (cho Debian Linux). Việc download và cài đặt các gói phần mềm này không khó. Trong tất cả các distro này đều hỗ trợ cơ chế cài đặt tự động (trình cài đặt sẽ kết nối đến Server của hãng và tải gói phần mềm được yêu cầu về và tiến hành cài đặt). Với những phiên bản mới nhất, Squid là 1 tùy chọn cài đặt trong quá trình cài đặt hệ điều hành.

Trong bản demo này, tôi tiến hành trên bản Fedora Core 8, một phiên bản rất ổn định của Redhat Linux, yêu cầu cấu hình không cao, dễ cấu hình, quản trị. Đối với những quản trị viên đã có kinh nghiệm về Linux, có thể sử dụng bản Ubuntu Server 7.10 (chỉ có giao diện command line). Đây là bản cũng thích hợp cho môi trường doanh nghiệp cỡ trung bình, phục vụ khoảng 1000-2000 người dùng.

Khởi động Squid

Sử dụng lệnh chkconfig để cấu hình chạy Squid mỗi khi khởi động máy:[root@proxy tmp]# chkconfig squid on

Sử dụng câu lệnh service để start, stop, và restart Squid sau khi đã khởi chạy:[root@proxy tmp]# service squid start[root@proxy tmp]# service squid stop[root@proxy tmp]# service squid restartSử dụng câu lệnh pgrep để kiểm tra Squid có đang chạy hay không:

[root@proxy tmp]# pgrep squid

Kết quả câu lệnh trên sẽ là ProcessID của Squid

Hoặc bạn cũng có thể dùng câu lệnh:[root@proxy tmp]# ps –aux

File cấu hình Squid: /etc/squid/squid.conf

File cấu hình chính của Squid là squid.conf. Để cấu hình Squid, cần phải chỉnh sửa các thông số cần thiết trong file cấu hình và khởi động lại Squid

Page 16: Install Squid Windows

Thông số Visible Host Name

Squid sẽ không thể khởi chạy nếu không được cung cấp tên máy. Để cung cấp thông số này, hiệu chỉnh thông số visible_hostname. Ở đây, hostname là tên của Proxy server

visible_hostname proxy

Các danh sách truy cập: Access Control Lists

Để giới hạn người dùng duyệt web, chúng ta sử dụng access control lists (ACLs). Mỗi dòng ACL định nghĩa một loại giới hạn hoạt động cụ thể, ví dụ như thời gian truy cập hoặc mạng nguồn (thường là LAN). Các dòng ACL sau đó được liên kết tới các phát biểu http_access tương ứng, cung cấp thông tin cho Squid Allow hay Deny yêu cầu khi yêu cầu nằm trong phạm vi của ACLSquid so sánh mỗi yêu cầu truy cập web mà nó nhận được bằng cách kiểm tra danh sách http_access từ đầu tới cuối. Nếu nó tìm thấy 1 phát biểu phù hợp, nó sẽ áp dụng để Allow hay Deny và dừng không đọc tiếp các phát biểu phía dưới nữa. Do vậy, chúng ta cần phải cẩn thận khi sắp sếp các phát biểu. Không được đặt các phát biểu Deny bên trên các phát biểu Allow trong khi muốn Allow các ACL thỏa mãn phát biểu đó. Cuối cùng, phải có phát biểu:http_access deny allđể từ chối tất cả các yêu cầu mà không được nói đến trong các phát biểu trước đó.

MỘT VÀI VÍ DỤ

Giới hạn truy cập web theo thời gian

Chúng ta có thể tạo ACL với các thông số là thời gian. Ví dụ, nếu muốn chỉ cho phép truy cập web trong thời gian làm việc, trong khi cấm truy cập đến host 192.168.1.123, chúng ta thực hiện như sau:

## Thêm các dòng ACL này vào phía trên trong đoạn ACL trong squid.conf#acl home_network src 192.168.1.0/24acl business_hours time M T W H F 9:00-17:00acl RestrictedHost src 192.168.1.23

## Thêm các phát biểu sau vào phần dưới cùng của đoạn http_access trong file squid.conf#http_access deny RestrictedHost http_access allow home_network business_hours

#chú ý rằng phát biểu deny phải đặt trước

Hoặc nếu chỉ muốn cho truy cập vào buổi sáng: ## Thêm dòng ACL này vào phía trên trong đoạn ACL trong squid.conf#acl mornings time 08:00-12:00

#

Page 17: Install Squid Windows

# Thêm phát biểu sau vào phần dưới cùng của đoạn http_access trong file squid.conf#http_access allow mornings

Giới hạn truy cập tới các đã website xác định

Để giới hạn người dùng không truy cập đến những website không được phép, chúng ta có thể lưu danh sách các website đó vào trong 1 file. Squid có thể đọc những file chứa danh sách các website hoặc domain để sử dụng trong các ACL. Ví dụ, chúng ta có 2 danh sách được lưu trong 2 file:/usr/local/etc/allowed-sites.squid/usr/local/etc/restricted-sites.squid.Với nội dung các file như sau:# File: /usr/local/etc/allowed-sites.squidwww.openfree.orgwww.ncsteam.com# File: /usr/local/etc/restricted-sites.squidwww.porn.comillegal.comChúng ta có thể sử dụng để ngăn chặn các site bị giới hạn và cho phép truy cập các site không bị giới hạn trong suốt thời gian làm việc như ví dụ dưới đây:

## Thêm vào phía dưới của đoạn ACL trong squid.conf

#acl home_network src 192.168.1.0/24acl business_hours time M T W H F 9:00-17:00acl GoodSites dstdomain "/usr/local/etc/allowed-sites.squid"acl BadSites dstdomain "/usr/local/etc/restricted-sites.squid"

## Thêm vào phần đầu tiên của đoạn http_access trong squid.conf#http_access deny BadSiteshttp_access allow home_network business_hours GoodSites

Giới hạn truy cập web theo IPChúng ta có thể tạo các ACL để giới hạn truy cập web của người dùng cụ thể thông qua địa chỉ IP mà họ sử dụng. Trong ví dụ dưới, chúng ta định nghĩa giải địa chỉ LAN là 192.168.1.0## Thêm vào phía dưới của đoạn ACL trong squid.conf#acl home_network src 192.168.1.0/255.255.255.0

Thêm phát biểu http_access tương ứng cho phép các địa chỉ IP thỏa mãn ACL## Thêm vào phần đầu tiên của đoạn http_access trong squid.conf#http_access allow home_network

Ngoài ra, chúng ta có thể cấu hình để xác thực người dùng thông qua User name và password. Tham khảo thêm tài liệu về Squid để biết thêm chi tiết.

Page 18: Install Squid Windows

Bắt buộc tất cả người dùng phải sử dụng Squid

Để bắt buộc tất cả người dùng truy cập web đều phải thông qua Squid, chúng ta phải thiết lập firewall (Iptables) để chỉ cho phép duy nhất Squid server có khả năng truy cập internet. Người dùng muốn truy cập internet phải thông qua Squid. 

Cấu hình Squid Server trong suốt đối với người dùng

Để giới hạn chỉ cho Squid server truy cập web mà không phải chỉnh sửa gì các thông số proxy trong trình duyệt của người dùng, chúng ta phải cấu hình Squid tự động nhận các yêu cầu kết nối web (transparent) của người dùng.

Các version trước 2.6: Chúng ta cấu hình các thông số như sau:

httpd_accel_host virtualhttpd_accel_port 80httpd_accel_with_proxy onhttpd_accel_uses_host_header on

Các Version từ 2.6 trở về sau: thêm từ khóa transparent đằng sau dòng khai báo port:http_port 8080 transparent

Cấu hình Iptable để hỗ trợ Squid Transparent ProxyĐể bắt buộc tất cả các yêu cầu kết nối web đều phải thông qua Squid proxy, chúng ta thực hiện cấu hình Iptable như sau:iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 \-j REDIRECT --to-port 3128iptables -A INPUT -j ACCEPT -m state \--state NEW,ESTABLISHED,RELATED -i eth1 -p tcp \--dport 3128iptables -A OUTPUT -j ACCEPT -m state \--state NEW,ESTABLISHED,RELATED -o eth0 -p tcp \--dport 80iptables -A INPUT -j ACCEPT -m state \--state ESTABLISHED,RELATED -i eth0 -p tcp \--sport 80iptables -A OUTPUT -j ACCEPT -m state \--state ESTABLISHED,RELATED -o eth1 -p tcp \--sport 80Với eth0 kết nối ra internet, eth1 kết nối tới mạng nội bộ, Squid và Iptables nằm trên cùng 1 server

Để biết thêm chi tiết trong các trường hợp khác, như nhiều LAN, Iptables và Squid nằm trên server khác nhau, các thủ thuật optimize Squid......các bạn hãy tham khảo thêm tài liệu chi tiết về Squid (tại www.squid-cache.org) và tài liệu quản trị vận hành Linux.