Squid is a widely used caching and forwarding HTTP web proxy. It is designed to optimize web traffic, improve response times, and save bandwidth. In this guide, we will walk you through the installation and configuration of Squid Proxy Server on Rocky Linux or Alma Linux 9. Whether you're setting it up on a local server or a Windows VPS UK, this tutorial will provide all the necessary steps.
Step 1: Update Your System
Before installing Squid, ensure your system is up to date. Run the following commands:
sudo dnf update -y
Keeping your system updated is essential for security and performance, whether you are deploying Squid locally or on a VPS Windows Servers platform.
Step 2: Install Squid Proxy Server
You can install Squid using the default package manager. Execute the following command:
sudo dnf install squid -y
After installation, enable and start the Squid service:
sudo systemctl enable squid
sudo systemctl start squid
You can check the status of the Squid service with:
sudo systemctl status squid
Step 3: Configure Squid Proxy Server
The main configuration file for Squid is located at /etc/squid/squid.conf
. Open this file in your preferred text editor:
sudo nano /etc/squid/squid.conf
Here, you can customize various settings. To allow access from specific IP addresses, add the following line at the end of the file:
acl allowed_ips src 192.168.1.0/24
Replace 192.168.1.0/24
with your actual network or specific IP addresses that you want to grant access. Then, allow the defined ACL:
http_access allow allowed_ips
Save the changes and exit the editor.
Step 4: Configure Firewall
If you have a firewall enabled, you will need to allow traffic on the default Squid port (3128). Use the following command to add the rule:
sudo firewall-cmd --add-port=3128/tcp --permanent
Then reload the firewall for the changes to take effect:
sudo firewall-cmd --reload
Step 5: Testing the Squid Proxy Server
After configuring Squid, it is important to test the proxy to ensure it is functioning correctly. You can do this by setting up your web browser to use the Squid server as a proxy. In your browser settings, configure the proxy settings to point to your server's IP address and port 3128.
Visit a website to confirm that the traffic is passing through the Squid proxy. You can also check the Squid logs for access records:
sudo tail -f /var/log/squid/access.log
Step 6: Secure Squid with SSL (Optional)
For added security, consider configuring Squid to use SSL. You will need to install additional dependencies and configure SSL certificates for secure connections. You can use Let's Encrypt to obtain free SSL certificates. First, install Certbot:
sudo dnf install certbot -y
Then follow the steps to obtain your SSL certificate:
sudo certbot certonly --standalone -d your-domain.com
After obtaining the certificate, you can configure Squid to use SSL by editing the configuration file accordingly. Ensure you update your firewall rules to allow HTTPS traffic as well.