GOAL:
To allow two differnet groups of people to access the Internet within valid times and to block certain websites.
ITEMS USED:
HERE WE GO:
We want squid to authenticate all our users, so enable authenticate_program in the squid.conf file:
authenticate_program /usr/local/sbin/ncsa_auth /usr/local/etc/squid/squid.passwd
The authentication program we use is ncsa_auth which is located /usr/local/sbin/ncsa_auth. This program needs a file that contains a list of users and thier passwords.
I wrote a program that is run from crontab at set periods, that ensures the file /usr/local/etc/squid/squid.passwd is current. Below is a copy of the perl program, if you use this program you will need to adapt this for your system. The program does more than just write out a password file, it creates 2 lists of users which we will use later. Don't forget to do a chmod 755 on the script:-).
#!/usr/bin/perl $temp = '';
open (WWWACCESS,"/usr/local/etc/squid/squid.passwd") || die
"can't open file: $!"; # Exit if password file has not been changed
exit; my ($user) = @_; foreach $auser (@passwords) { return("$userid:$passwd\n"); my ($thisguid, $writeFile,$skipAdd) = @_; open (WWWACCESS,">$writeFile") || die "can't open file: $!"; foreach $auser (@passwords) { |
When to have run this program you will have 3 file in your squid folder:-
Now we have to create some squid Access Lists (acl's) in the squid.conf file:
acl students proxy_auth "/usr/local/etc/squid/student.users"
acl staff proxy_auth "/usr/local/etc/squid/staff.users"
acl password proxy_auth 300
Above we have created 3 new acl's, the last rule is a standard rule. The first 2 rules tell squid that there are 2 rules called students and staff. Now we have to put the rules to use, do the following in the squid.conf file:
http_access deny !students !staff
What if we want staff to have access to the web anytime but students can only access the web during supervised periods? We to do this we create another acl rule for squid.conf:
acl okTime time MTWHF 09:00-18:30
The above rule allows access to the web between 9am and 6.30pm weekdays. Now we have to combine the okTime rule with the students rule:
http_access deny students !okTime
To summarise you should have the following in the squid.conf file:
authenticate_program /usr/local/sbin/ncsa_auth /usr/local/etc/squid/squid.passwd
acl students proxy_auth "/usr/local/etc/squid/student.users"
acl staff proxy_auth "/usr/local/etc/squid/staff.users"
acl okTime time MTWHF 09:00-18:30
acl password proxy_auth 300
http_access deny !students !staff
http_access deny students !okTime
(Rest will be done soon).