How to Install Squid on RHEL

How to Install Squid Proxy on RHEL

Webmasters and server administrators often face the challenge of optimizing their network performance and ensuring secure, fast, and reliable internet access for their users.

One of the most effective solutions to this problem is the use of a proxy server. Among the various proxy server software available, Squid stands out as a robust, open-source, caching proxy that supports a variety of protocols like HTTP, HTTPS, FTP, and more.

By installing Squid on your RHEL server, you can not only improve your network’s performance but also save bandwidth, reduce response times, and enhance security.

In this tutorial, we will guide you step-by-step on how to install Squid on RHEL, ensuring you reap all the benefits of a top-tier proxy server.

Let’s get started!

Step 1: Update Your System

Before installing any new software, it’s always a good practice to update your system. Run the following command:

yum update -y

Step 2: Install Squid

Once your system is updated, you can install Squid using the following command:

yum install squid -y

Step 3: Start and Enable Squid Service

After the installation, start the Squid service and enable it to launch at boot:

systemctl start squid
systemctl enable squid

Step 4: Configure Squid

The main configuration file for Squid is located at /etc/squid/squid.conf. This file contains a plethora of settings that allow you to customize Squid’s behavior, caching rules, access controls, and more. Before making any changes, it’s a good practice to create a backup of the original configuration file.

cp /etc/squid/squid.conf /etc/squid/squid.conf.backup

Now, you can proceed to edit the configuration file:

vi /etc/squid/squid.conf

Here are some common configurations you might consider:

See also  How to Configure Squid Proxy Server for Transparent Proxying

Define Allowed Networks:

By default, Squid denies access to all incoming requests. You need to define which networks or IP addresses are allowed to use the proxy.

acl localnet src  # Adjust this to your local network IP range
http_access allow localnet

Set Cache Size:

You can define the amount of disk space Squid should use for caching. For example, to set the cache size to 500 MB:

cache_dir ufs /var/spool/squid 500 16 256

Define Cache Refresh Patterns:

This determines how frequently Squid checks the origin server for a fresh copy of the content. For example, to set a refresh pattern for images:

refresh_pattern \.(gif|png|jpg|jpeg|ico)$ 10080 90% 43200

This means images will be cached for 10080 minutes (7 days), and Squid will consider the cached version fresh for up to 90% of that time. After that, it will only check the origin server every 43200 minutes (30 days).

Set Access Logs:

By default, Squid logs all accessed URLs. If you want to change the location of the access log or disable it:

# To change the location
access_log /path/to/your/log/file.log

# To disable access logging
access_log none

After making your desired changes, save the file and exit the editor (in vi, press Esc, type :wq, and hit Enter).

See also  How to Install and Configure Squid Proxy Server on CentOS 6.2

Step 5: Allow Port 3128 in Firewall

By default, Squid listens on port 3128. Ensure this port is open in your firewall:

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

Step 6: Test Squid Configuration

After making changes to the configuration, it’s essential to test Squid:

squid -k parse

If there are no errors, you can restart Squid to apply the changes:

systemctl restart squid

Commands Mentioned:

  • yum update -y – Updates the system packages
  • yum install squid -y – Installs Squid proxy server
  • systemctl start squid – Starts the Squid service
  • systemctl enable squid – Enables Squid to start on boot
  • vi /etc/squid/squid.conf – Opens the Squid configuration file for editing
  • firewall-cmd –permanent –add-port=3128/tcp – Adds port 3128 to the firewall
  • firewall-cmd –reload – Reloads the firewall configuration
  • squid -k parse – Tests the Squid configuration
  • systemctl restart squid – Restarts the Squid service


Installing Squid on RHEL is a straightforward process that can significantly enhance your network’s performance. By following the steps outlined in this tutorial, you’ve equipped your RHEL server with a powerful caching proxy that can speed up web access, save bandwidth, and bolster security.

See also  How to Use Squid Proxy Server for Network Debugging

Remember, the key to maximizing Squid’s potential lies in its configuration. Dive deep into the Squid’s features and benefits to tailor it to your specific needs.

I hope this guide has been informative and valuable. If you have any questions or insights, please comment below. We’d love to hear your feedback and experiences.


  1. What is the primary purpose of Squid?

    Squid is primarily used as a caching proxy server. It caches frequently accessed web content, reducing bandwidth usage and improving web access speeds.

  2. Can Squid handle HTTPS requests?

    Yes, Squid can handle HTTPS requests and can be configured to perform SSL bumping, allowing it to decrypt, inspect, and re-encrypt traffic.

  3. Is Squid compatible with other Linux distributions?

    Yes, Squid is versatile and can be installed on various Linux distributions, including Ubuntu, Debian, CentOS, and more.

  4. How can I optimize Squid for better performance?

    Optimizing Squid involves tweaking its configuration, adjusting cache sizes, setting appropriate refresh patterns, and monitoring its performance regularly.

  5. Can Squid be used for content filtering?

    Yes, Squid can be integrated with content filtering solutions to block specific websites, domains, or content types, enhancing network security.


Leave a Reply

Your email address will not be published. Required fields are marked *