RHEL BasedRocky Linux

How To Install Squid Proxy on Rocky Linux 9

Install Squid Proxy on Rocky Linux 9

In this tutorial, we will show you how to install Squid Proxy on Rocky Linux 9. For those of you who didn’t know, Squid Proxy is an open-source caching and forwarding HTTP proxy server that enables clients to access web resources while hiding their identity and improving browsing speed through content caching. By deploying Squid Proxy on Rocky Linux 9, you can optimize network performance and enhance security by filtering access to specific websites.

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 the step-by-step installation of the Squid Proxy on Rocky Linux 9 or RHEL-based.

Prerequisites

  • A server running one of the following operating systems: Rocky Linux 9.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies for Squid Proxy.
  • 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 Rocky Linux 9

Step 1. Before proceeding with Squid installation, update and upgrade your Rocky Linux system to the latest packages. This ensures security fixes and the latest software versions are installed:

sudo dnf update

Step 2. Installing Squid Proxy on Rocky Linux 9.

 Once the system is updated, you can proceed with the installation of Squid by running the following command:

sudo dnf install squid

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

sudo systemctl start squid
sudo systemctl enable squid

To verify that Squid is up and running, check its status:

sudo systemctl status squid

Step 3. Configuration of Squid Proxy.

Configuring Squid is a crucial step in customizing the proxy server according to your requirements. Before making any changes, create a backup of the default configuration file to revert in case of errors:

sudo cp /etc/squid/squid.conf /etc/squid/squid.conf.bak

By default, Squid listens on port 3128. To change this, open the squid.conf file:

sudo nano /etc/squid/squid.conf

Look for the line starting with http_port. To listen on a specific IP and port, edit the line as follows:

http_port <IP_ADDRESS>:<PORT>

Replace <IP_ADDRESS> with the desired IP address (e.g., 192.168.1.100) and <PORT> with the desired port number (e.g., 8080).

Access Control Lists (ACLs) allow you to control which clients can access specific resources. To configure ACLs, add the following lines to squid.conf:

acl internal_network src <INTERNAL_NETWORK_IP_RANGE>

Replace <INTERNAL_NETWORK_IP_RANGE> with the range of IP addresses that belong to your internal network (e.g., 192.168.1.0/24).

To allow access to specific websites, create an ACL and then define rules accordingly. For example, to allow access to example.com, add the following lines to squid.conf:

acl allowed_websites dstdomain .example.com
http_access allow allowed_websites

Caching helps reduce bandwidth usage and speeds up content delivery. To enable caching, add the following lines to squid.conf:

cache_dir ufs /var/spool/squid 10000 16 256

These settings allocate 10,000 MB of disk space for caching with 16 cache directories and 256 subdirectories.

Logging is essential for monitoring Squid’s activity and diagnosing potential issues. Add the following lines to squid.conf to enable logging:

access_log /var/log/squid/access.log

Step 4. Verify Squid.

To verify that Squid is working as expected, you can use a web browser to connect to the proxy server. In the web browser, go to the proxy server IP address and port number. For example, if the IP address of the proxy server is 192.168.1.100 and the port number is 3128, you can enter the following URL in the web browser:

http://192.168.1.100:3128

If Squid is working correctly, you should see a message that says “Access denied” or “ERR_ACCESS_DENIED“. This is because Squid is configured to deny access by default. You can modify the configuration file to allow access to specific IP addresses or networks.

Congratulations! You have successfully installed Squid. Thanks for using this tutorial for installing the Squid Proxy on your Rocky Linux 9 system. For additional help or useful information, we recommend you check the official Squid website.

VPS Manage 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 “VPS Manage Service Offer”, 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