How to block URLs using squid proxy

How block websites  using squid proxy?

Squid Proxy, URL blocking

With our guide we are going to show you how to block website URL’s using squid proxy .

We assume that you have installed squid already, if not as you can install squid package.

#yum install squid

With our guide we are going to cover:

1. Define the ACL
2. Activate the ACL.
3. Editing squid.conf

1. Define the ACL.

Syntax:
acl aclname acltype “acl file name with location”

Note :
acl: access control list

Example:
acl blocked_sites dstdomain “/etc/squid/acls/blocked_sites.txt”

2.Activation of ACL

The activation of acl should be on top of allow because deny over rights allow.

Syntax:
http_access deny aclname
OR

http_access allow aclname

Example :

http_access deny blocked_sites
http_access allow localnet

Note:
If you have defined the acl for localnet (acl localnet src 192.168.0.0/23), this is how you can activate it.

http_access allow localhost

OR

http_access allow all

3. Editing squid.conf

Let’s take you to sample acl to block yahoo.com,rediff.com and youtube.com
#vi /etc/squid/squid.conf

******go to the line localnet section and define the acl based on LAN **********
acl localnet src 192.168.0.0/23 # RFC1918 possible internal network
**** down the line of localnet , define the url blocking usig acl type:dstdomain*******
acl blocked_sites dstdomain "/etc/squid/acls/blocked_sites.txt"
****go to the line http_access allow localnet add below acl activation entry top of this line***
http_access deny blocked_sites

Save & Exit!

Create a file to specify the URL’s denied in our previous step

Create a folder “acls”  under the /etc/squid/. You can create it in your desired location within the file system. In our guide we are using the location “/etc/squid/acls” and the file name to block destination domains “blocked_sites.txt”

#mkdir /etc/squid/acls

Create a file to add the domains denied. Specify each in a separate line.

#vi /etc/squid/acls/blocked_sites.txt

Yahoo.com

Gmail.com

Youtube.com

Save & Exit!

Reload squid configuration file changes to take effect.

#service squid reload

 

 

Reload squid configuration file changes to take effect.

#service squid reload

 

Both comments and pings are currently closed.

Comments are closed.

Copyright ©Solutions@Experts.com
Copyright © NewWpThemes Techmark Solutions - www.techmarksolutions.co.uk