CentOSLinuxTutorials

How To Install Squid Proxy on CentOS 8

Install Squid Proxy on CentOS 8

In this tutorial, we will show you how to install Squid Proxy on CentOS 8. For those of you who didn’t know, Squid is a caching proxy for the Web supporting HTTP, HTTPS, FTP, and more. Squid proxy is used by various organizations and internet providers to reduce bandwidth and to increase response time.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you through the step-by-step installation of Squid on a CentOS 8 server.

Prerequisites

  • A server running one of the following operating systems: CentOS 8.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install Squid Proxy on CentOS 8

Step 1. First, let’s start by ensuring your system is up-to-date.

sudo dnf update

Step 2. Installing Squid Proxy on CentOS 8.

Squid proxy is available on the default CentOS 8 repositories and can be installed by running the command:

sudo dnf install squid

Once the installation is done, start and enable it on system startup using the following commands:

sudo systemctl enable --now squid

Step 3. Configuring Squid Proxy.

Before you can begin to customize the Squid configuration to suit your needs, create the configuration file backup:

sudo cp /etc/squid/squid.conf /etc/squid/squid.conf.ori

Now we open squid’s main configuration file and add/edit the following:

nano /etc/squid/squid.conf
# Recommended minimum configuration:
auth_param basic program /usr/lib/squid/ncsa_auth /etc/squid/squid_passwd
acl ncsa_users proxy_auth REQUIRED
http_access allow ncsa_users

acl manager proto cache_object
acl localhost src 127.0.0.1/32
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32
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 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

http_access allow manager localhost
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access deny all
http_port 3128

hierarchy_stoplist cgi-bin ?
coredump_dir /var/spool/squid
cache deny all

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

icp_port 3130
forwarded_for off

request_header_access Allow allow all
request_header_access Authorization allow all
request_header_access Proxy-Authorization allow all
request_header_access Proxy-Authenticate allow all
request_header_access Cache-Control allow all
request_header_access Content-Encoding allow all
request_header_access Content-Length allow all
request_header_access Content-Type allow all
request_header_access Date allow all
request_header_access Expires allow all
request_header_access Host allow all
request_header_access If-Modified-Since allow all
request_header_access Last-Modified allow all
request_header_access Location allow all
request_header_access Pragma allow all
request_header_access Accept allow all
request_header_access Accept-Charset allow all
request_header_access Accept-Encoding allow all
request_header_access Accept-Language allow all
request_header_access Content-Language allow all
request_header_access Mime-Version allow all
request_header_access Retry-After allow all
request_header_access Title allow all
request_header_access Connection allow all
request_header_access Proxy-Connection allow all
request_header_access User-Agent allow all
request_header_access Cookie allow all
request_header_access All deny all
visible_hostname idroot.us

Then, create our authentication file which Squid can use to verify for user authentications:

htpasswd -b /etc/squid/squid_passwd username password

Step 4. Configure firewall for Squid.

If a firewall is enabled, allow the Squid port. Replace the port if you have changed the default:

firewall-cmd --add-port=3128/tcp --permanent
firewall-cmd --reload

Finally done step configuration part now time to test browsing pointing squid IP and default port in the client browser. On your Firefox, configure it to connect to the external network via your Squid server. Preferences > General > Network Settings > Manual Proxy Configuration. Check to Use this proxy server for all protocols.

Congratulations! You have successfully installed squid. Thanks for using this tutorial for installing squid proxy on CentOS 8 system. For additional help or useful information, we recommend you check the official squid website.

Squid Install Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “Squid Proxy” installation, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button