Linux Squid Proxy server – Installation and configuration – Internet access control
A Proxy server servers web pages to your users, connecting to the Internet on their behalf. Users therefore don’t connect to the Internet directly. Many companies would like to monitor and or control users access to the Internet. Linux uses Squid as a proxy server.
Install squid from your installation CD or download from the internet.
Initial setup
For a very basic configuration configure as follows:
1. Vi the file /etc/squid/squid.conf
2. If this file is empty install squid first
3. Remove the # in front of the following lines
a. Port http_port 3128
b. Cache_8mb
c. Cache_swap_low 90
d. Casche_swap_high 95
e. Cache_dir ufs
f. Cache_access_log
g. Cache_log
4. Go down to “access control” and change (default is “deny all”)
5. If you want squid to always start at boot, type the command “chkconfig squid on”
6. Start the squid server with the command “service squid start” or if you use SuSE “rcsquid start”
The next thing you need to do is create an “access rule”. The squid .conf file has two basic section, the ACL section, where you define your rule; and the ACCESS section where you define how the rule is applied.
Access only from LAN
For a simple rule that allows access to the Internet from your LAN continue as follows:
1. find the “ACL” section of the “squid.conf” file. Scroll down to “recommended minimum configuration” and add the line (or whatever you LAN address should be):
acl lan_local src 192.168.1.0/24
2. Now scroll down to the “http_access” setion of the ‘quid.confï” file and find “http_access allow manager localhost”. Put a space between it and the one bellow and insert the following:
http_access allow lan_local
Notice that the part “lan_local” is the rule you set up in point 1
Allowing access certain times of the day:
The following is an example how to restrict access to lunch time:
Add this to the bottom of the ACL section of squid.conf
acl luchtime time 12:00-13:00
Add this at the top of the http_access section of squid.conf
http_access allow lunchtime
Access controlled by password:
The following is an example how to restrict access by password using NCSA Password Authentication:
Squid comes with a program called ncsa_auth that reads any NCSA-compliant encrypted password file. You can use the htpasswd2 program that comes installed with Apache2 to create your passwords.
Create the password file. The name of the password file could be /etc/squid/squid_passwd, and you need to make sure that it’s universally readable. To do this type the following at the command prompt:
touch /etc/squid/squid_passwd
chmod o+r /etc/squid/squid_passwd
Use the”htpasswd2″ program to add users to the password file. You can add users at anytime without having to restart Squid. In this example, I create a user called “fred”. To do this, type the following at the command prompt
htpasswd2 /etc/squid/squid_passwd fred
You will then be asked to confirm the password
Next you need to find the location of your “ncsa_auth” file using the rpm command. Type the following at the command prompt:
rpm -ql squid | grep ncsa
Take note of the path to that file.
Now edit “squid.conf” to define the authentication program in squid.conf, “ncsa_auth”.
Next, create an “ACL” named “ncsa_users” with the “REQUIRED” keyword that forces Squid to use the “NCSA auth_param”. Finally, create an “http_access” entry that allows traffic that matches the “ncsa_users ACL” entry.
Here is how to do it:
Add the following to the”auth_param” section of the “squid.conf” file.
auth_param basic program /usr/lib/squid/ncsa_auth /etc/squid/squid_passwd
Use the path you took note of earlier to find the ncsa_auth file.
Now add the following to the bottom of the “ACL” section of the “squid.conf” file.
acl ncsa_users proxy_auth REQUIRED
Then add the following to the top of the “http_access” section of the “squid.conf” file.
http_access allow ncsa_users
Squid will now ask users for a password.
Require a user password during work hours but not during lunch:
Combine the time control with password control as follows:
Under “http_access”, put the “hours” access above the “password” access.
http_access allow lunchtime
http_access allow ncsa_users

