ndzlogo-1-1
Loading ...

INDIA – HEADQUARTERS

INDIA

UNITED STATES

CANADA

Squid is one of the most popular proxy server which can be employed to run on linux servers.

Let us see how to block accessing certain sites using Squid.

Step 1 » create a file named as ( /etc/squid/blockedsites.squid ) and insert the site names one per line.

Like;

[root@server ~]# cat /etc/squid/blockedsites.squid
 #blocked sites
 www.yahoomail.com
 www.gmail.com

Step 2 » Open the /etc/squid/squid.conf and create a new acl(Access Control  List) ” blocksites” and acl type “dstdomain” in the acl section like the below .

acl Safe_ports port 488         # gss-https
acl Safe_ports port 591         # filemaker
acl Safe_ports port 777         # multiling https
acl CONNECT method CONNECT
# ACL blocksites
acl blocksites dstdomain “/etc/squid/blockedsites.squid”

 

Then add the following line “https_access deny blocksites” to https_section to deny the access to the acl “blocksites” .

 

# Recommended minimum Access Permission configuration:
# Only allow cachemgr access from localhost
https_access allow manager localhost
# Deny access to blocksites ACL
https_access deny blocksites

 

Step 3 » Time to restart squid service

[root@server ~]# service squid restart

 

Restricting Access to specific keywords :

Step 1 » create a file ( /etc/squid/blockkeywords.squid ) and insert the keywords one per line.

[root@server ~]# cat /etc/squid/blockkeywords.squid
#blocked keywords
sex
porn

Step 2 » Open the /etc/squid/squid.conf and create a new acl(Access Control List) “blockkeywords” and acl type “url_regex” in the acl section.

# ACL blocksites

acl blocksites dstdomain “/etc/squid/blockedsites.squid”
# ACL blockkeywords
acl blockkeywords url_regex -i “/etc/squid/blockkeywords.squid”

 

Then insert the following line “https_access deny blockkeywords” to https_section to deny the access to the acl
“blockkeywords” .

 

https_access allow manager localhost
# Deny access to blocksites ACL
https_access deny blocksites
# Deny access to blockkeywords ACL
https_access deny blockkeywords