How to allow certain domains or IP addresses in Squid Proxy Server

Home > Search > How-to
  by

Lets say we want to permit access to most every website on the Internet, but deny certain websites. Create a file named blocked_sites.

[root@server1 ~]# touch blocked.sites

 

Add the sites to be blocked to the blocked_sites file.

www.example.com

 

Add the following in /etc/squid/squid.conf or /etc/squid3/squid.conf:

acl blocked_sites dstdomain "/etc/squid/blocked.sites"
http_access deny blocked_sites

 

Restart Squid, and ensure Squid is active and running.

[root@server1 ~]# systemctl restart squid
[root@server1 ~]# systemctl status squid

 

www.example.com should now produce the following:

 


Access can also be denied for certain keywords. Create a file named blocked_keywords.

[root@server1 ~]# touch blocked.keywords

 

Add the sites to be blocked to the blocked_sites file.

porn
pornography

 

acl blocked_keywords url_regex -i "/etc/squid/blocked.keywords"
http_access deny blocked_keywords

 

Restart Squid, and ensure Squid is active and running.

[root@server1 ~]# systemctl restart squid
[root@server1 ~]# systemctl status squid

 

Porn websites should now produce the following:

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter in the box below so that we can be sure you are a human.




Comments