How to Install Squid on CentOS 7 / RHEL 7

now I will install squid RPM using yum, yum is a famous package manager for RPM based Operating Systems like Fedora, CentOS and Red Hat.

 

Step 1:

To install squid RPM and dependencies using the yum command.

yum install squid -y

Sample Output:

Installed:
squid.x86_64 7:3.3.8-11.el7

 

Dependency Installed:
libecap.x86_64 0:0.2.0-8.el7
perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7
perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7
perl-DBI.x86_64 0:1.627-4.el7
perl-Data-Dumper.x86_64 0:2.145-3.el7
perl-Digest.noarch 0:1.17-245.el7
perl-Digest-MD5.x86_64 0:2.52-3.el7
perl-IO-Compress.noarch 0:2.061-2.el7
perl-Net-Daemon.noarch 0:0.48-5.el7
perl-PlRPC.noarch 0:0.2020-14.el7

Squid is installed successfully from RPM, by default squid generate its configuration file under /etc/squid directory.

Step 2:

Let’s perform steps for basic configuration:

  •  Allow our network in acl.
  •  Add visible hostname

Edit squid.conf file which is located here /etc/squid/squid.conf
Its recommended to create backup of default configuration file to be on safe side.

cp /etc/squid/squid.conf /etc/squid/squid.conf.org.back

 

Now open config file in vi text editor.

vi /etc/squid/squid.conf

 

Add 192.168.2.0/24 network as follows

acl broexperts_network src 192.168.2.0/24
http_access allow broexperts_network

 

Un-comment and adjust the following to add cache directory.

cache_dir ufs /usr/local/squid/var/cache/squid 100 16 256

 

And at the last of config file add visible hostname

visible_hostname pxy.broexperts.com

 

See below my recommended minimum squid.conf file:

# Recommended minimum configuration:
# Adapt to list your (internal) IP networks from where browsing
# should be allowed

 

acl broexperts_network src 192.168.2.0/24

acl SSL_ports port 443
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl CONNECT method CONNECT

#
# Recommended minimum Access Permission configuration:
#
# Deny requests to certain unsafe ports
http_access deny !Safe_ports

# Deny CONNECT to other than secure SSL ports
http_access deny CONNECT !SSL_ports

# Only allow cachemgr access from localhost
http_access allow localhost manager
http_access deny manager

# from where browsing should be allowed
http_access allow localhost
http_access allow broexperts_network

# And finally deny all other access to this proxy
http_access deny all

# Squid normally listens to port 3128
http_port 3128

# Uncomment and adjust the following to add a disk cache directory.
cache_dir ufs /var/spool/squid 100 16 256

# Leave coredumps in the first cache dir
coredump_dir /var/spool/squid

#
# Add any of your own refresh_pattern entries above these.
#
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern . 0 20% 4320
visible_hostname pxy.broexperts.com

Now save and exit.

 

Step 3:

Start squid service and make it available on startup.

service squid start
chkconfig squid on

 

Step 4:

Add firewall rule to allow squid 3128 port.

iptables -I INPUT -p tcp –dport 3128 -j ACCEPT

 

Save rules and restart iptables service

service iptables save
service iptables restart

Done configuration part now time to test browsing pointing squid ip and default port in client browser.

 

Step 5:

Open up firefox browser and go to Tools > Options > Advance tab > Network > Settings > select manual proxy settings radio button and provide squid server IP 192.168.1.100 and port 3128 and check use this use this proxy server for all protocols and then click oK.

 

 tail -f /var/log/squid/access.log



source:  broexperts.com

Помог ли вам данный ответ? 0 Пользователи нашли это полезным

Связанные статьи

How to Install Bind (Named) on CentOS 7 / RHEL 7

The Domain Name System (DNS) is a hierarchical distributed naming system for computers, services,...

How To Setup Squid Authenticate with Radius on CentOS 6.4

n this how to, I assume you already have a setup running FreeRADIUS server. I am going to share...

Install and Setup FreeRADIUS on CentOS 5, CentOS 6 and Ubuntu 11.10

A simple tutorial to setup and configure FreeRADIUS on CentOS 5 and Ubuntu 10.04.   Just...

How to Install Squid on CentOS 7 / RHEL 7 ( Easy Config )

[root@prox ~]#  yum -y install squid [root@prox ~]#  vi /etc/squid/squid.conf acl CONNECT...

How to Install OpenLiteSpeed ( LSWS ) on CentOS 7 / RHEL 7 /CentOS 6 / RHEL 6 /CentOS 5 / RHEL 5

CentOS 5, 6 & 7 Add the Repository Use the following commands to add our CentOS...