Linux menu

Tuesday, September 23, 2014

How to limit access through Squid proxy Server during specific hours In Linux

In continuation with Proxy Server series, In this article, we will learn to limit the access through proxy in specific hours ( probably working hours in an office)

Note: For Installing squid and basic configuration, please read How to configure Squid Proxy Server
1) Open the file /etc/squid/squid.conf and add the following lines:
[root@server ~]# vi /etc/squid/squid.conf
#  Define the acl for a particular time (do it in the acl definition section)  like:
acl my_network src 192.168.0.0/24
acl working_hours time M T W H F 9:00-17:00
acl Restricted src 192.168.0.27
a. my_network is the name of acl matching the network which we want to limit
b. working_hours is the name of acl defining the days and hours ( M T W H F stands for day of week like M for monday and 9:00-17:00 defines working hours)
c. Restricted is the name of acl defining a single ip address which is not allowed to access at all

2) Now add these lines at the top of the http_access section of the same file (/etc/squid/squid.conf)
http_access deny Restricted
http_access allow my_network working_hours
This means clients under my_network can access internet withinworking_hours and clients under Restricted acl will not be allowed at all.

3) Now save and exit the file and restart the squid service.


[root@server ~]# service squid restart
[root@server ~]# chkconfig squid on

No comments: