• Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial News Comments FAQ Related Articles

How to Block a Website Using Squid Proxy Server 4.7 version on CentOS 7.6

  • 00:16 squid -v
  • 00:23 cd /etc/squid
  • 00:35 vim squid.conf
  • 01:14 vim block.txt
  • 01:43 vim squid.conf
  • 02:16 squid -s
  • 02:30 chmod -R 1777 /var/logs
  • 02:33 squid -s
  • 02:36 ip a
{{postValue.id}}

To Blocking the websites using Squid Proxy Server

Procedure

Lets check the version of squid proxy server.

[root@linuxhelp ~]# squid -v
Squid Cache: Version 4.7-20190507-r2e17b0261
Service Name: squid
configure options:  '--prefix=/usr' '--includedir=/usr/include' '--datadir=/usr/share' '--bindir=/usr/sbin' '--libexecdir=/usr/lib/squid' '--localstatedir=/var' '--sysconfdir=/etc/squid'

Go to the location of Squid configuration file.

[root@linuxhelp ~]# cd /etc/squid

List the contents in the squid.

[root@linuxhelp squid]# ll
total 360
-rw-r--r-- 1 root root    692 May 31 09:12 cachemgr.conf
-rw-r--r-- 1 root root    692 May 31 09:12 cachemgr.conf.default
-rw-r--r-- 1 root root   1800 May 31 09:10 errorpage.css
-rw-r--r-- 1 root root   1800 May 31 09:12 errorpage.css.default
-rw-r--r-- 1 root root  12077 May 31 09:12 mime.conf
-rw-r--r-- 1 root root  12077 May 31 09:12 mime.conf.default
-rw-r--r-- 1 root root   2553 May 31 09:12 squid.conf
-rw-r--r-- 1 root root   2553 May 31 09:12 squid.conf.default
-rw-r--r-- 1 root root 318265 May 31 09:12 squid.conf.documented

Configure the squid.conf file as follows.

[root@linuxhelp squid]# vim squid.conf
acl test src 192.168.7.102
acl block dstdomain 

Create a file named block.txt to block the websites that are set in this file.

[root@linuxhelp squid]# vim block.txt
.facebook.com
.twitter.com

To know the exact location of the block.txt, execute the following command.

[root@linuxhelp squid]# pwd
/etc/squid

Open the squid configuration file and set the path in the dstdomain rule.

[root@linuxhelp squid]# vim squid.conf
acl test src 192.168.7.102
acl block dstdomain “/etc/squid/block.txt”
http_access deny test block
http_access allow test

Reload the squid proxy server.

[root@linuxhelp squid]# squid -s
WARNING: Cannot write log file: /var/logs/cache.log
/var/logs/cache.log: Permission denied
         messages will be sent to 'stderr'.

Set the sticky bit and full permissions to get rid of the above warning.

[root@linuxhelp squid]# chmod -R 1777 /var/logs

Reload the squid proxy sevrer.

[root@linuxhelp squid]# squid -s

Check the ip address of the squid proxy server by running the following command.

[root@linuxhelp squid]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 1000
    link/ether 00:0c:29:f9:d6:3d brd ff:ff:ff:ff:ff:ff
    inet 192.168.7.229/24 brd 192.168.7.255 scope global noprefixroute ens33
       valid_lft forever preferred_lft forever
    inet6 fe80::348f:40bb:9186:7a4/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
    link/ether 52:54:00:1c:2f:d7 brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
       valid_lft forever preferred_lft forever
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 1000
    link/ether 52:54:00:1c:2f:d7 brd ff:ff:ff:ff:ff:ff

Open the browser, click on open Menu: and select options. snap (1) Enter proxy in the search bar of Mozilla Firefox and select proxy settings. snap (2) Set the squid proxy server in the following way. snap (3) Open the www.facebook.com and www.twitter.com to verify the websites that had blocked by the squid proxy server that was set in the block.txt snap (4) snap (5) With this, blocking of websites using squid proxy server comes to end.

Tags:
frank
Author: 

Comments ( 1 )

manuelef
What is this --> 192.168.7.102 ?

can I replace this:
acl ??? src 192.168.110.0/24
acl block dstdomain “/etc/squid/block.txt”
http_access deny ??? block
http_access allow ???
Add a comment
{{postCtrl.cmtErrMsg}}

Frequently asked questions ( 5 )

Q

What is the path to set the squid proxy server in Google Chrome?

A

Click on Customize and Control Google Chrome, select settings -->enter "proxy" in the search bar of settings, Click on open proxy settings, and choose the Connections Menu-->click on LAN Settings is the path to set the squid proxy server in Google Chrome.

Q

What is the shortcut to set the squid proxy server?

A

Win+R --> enter inetcpl.cpl and click on LAN settings on the extreme right corner of the window.

Q

What are the options to be configured inside the squid proxy server LAN settings?

A

Under the proxy server, Check the two boxes and enter the squid IP in the address bar and the port number and click Ok. These are the options to be configured inside the squid proxy server LAN settings.

Q

What is the default port number of squid proxy server?

A

The defaults port number of squid proxy server is 3128

Q

Which side of the browser do i have to set the squid proxy server ?

A

The Ip that you have mentioned in the source field of the squid configuration file (192.168.7.102) side of the browser, has to be set the squid proxy server(192.168.7.229)

Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help David Lopez Guillen ?
Ayuda urgente instale SSL para servidor Opensuse y ahora no funciona tengo servicio web

hola segui este tutorial para tener un certificado ssl y ahora no se ve mi app en la red, espero alguien pueda ayudarme, tengo M9oodle en3.5 en un servidor open suse y ahora no funciona por favor ayuda.

https://www.linuxhelp.com/how-to-create-ssl-certificate-in-opensuse

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.