What is the Squid Proxy Server?
Squid is a robust, open-source caching proxy for the web supporting HTTP, HTTPS, FTP, and more. By caching frequently requested web pages and files, Squid reduces bandwidth usage and improves response times for users on a network. It also provides granular access control, allowing administrators to restrict internet access for specific IP addresses or domains.
Step 1: Install the Squid Package
Log in to your Ubuntu server and ensure your package repositories are up to date. Install the Squid package using the APT package manager:
sudo apt updatesudo apt install squid -y
Step 2: Understand the Configuration File
Squid’s behavior is dictated by its main configuration file. Before making changes, it is highly recommended to create a backup of the original file:
sudo cp /etc/squid/squid.conf /etc/squid/squid.conf.backup
Now, open the configuration file in a text editor:
sudo nano /etc/squid/squid.conf
Step 3: Configure Access Control Lists (ACLs)
By default, Squid denies all incoming requests from the local network. You must define an ACL to allow your local subnet to use the proxy. Locate the section containing acl localnet src and add your network range. For example:
acl mynetwork src 192.168.1.0/24
Next, scroll down to the http_access section and add a rule allowing the ACL you just created. Ensure this line is placed before the http_access deny all directive:
http_access allow mynetwork
Step 4: Restart the Squid Service
Save your changes and exit the text editor. To apply the new configuration, restart the Squid service:
sudo systemctl restart squid
You can verify that Squid is running and listening on its default port (3128) by executing:
sudo systemctl status squid
Step 5: Configure Client Browsers
Your Squid proxy server is now operational. To test it, open the network proxy settings on a client computer or web browser, specify the IP address of your Ubuntu server, and set the port to 3128. All HTTP/HTTPS traffic from the client will now be routed through and cached by the Squid server.