Accuracy note — 13 October 2026: Ubuntu 20.04 ended standard security maintenance in May 2025. Use a supported Ubuntu release for new installations, or confirm appropriate Ubuntu Pro coverage for an existing 20.04 system. See the Ubuntu release cycle. The access-control text below has been corrected; older screenshots may show the previous configuration.
Introduction: Squid Proxy
Configuring Squid Proxy on Ubuntu 20.04 is a straightforward process that can enhance your network’s performance and security. Begin by installing Squid with the command sudo apt-get install squid. Once installed, you can modify the Squid configuration file located at /etc/squid/squid.conf. This file allows you to set access control rules, cache settings, and network permissions. After making your adjustments, restart the Squid service with sudo systemctl restart squid to apply the changes. To ensure proper functionality, check the Squid status using sudo systemctl status squid. Properly configuring Squid Proxy can significantly improve your network’s efficiency and browsing experience.
Squid Proxy is a Linux-based application. This is a full-featured caching proxy supporting popular network protocols like HTTP, HTTPS, FTP, and more.
How to set up a Squid Proxy on Ubuntu 20.04
Now, let’s start with installing and configuring a squid proxy server on Ubuntu 20.04.
- Update the repository and install the required packages.
apt update -y apt install vim screen curl net-tools -y
- install squid service
apt -y install squid
Squid service have installed succesfully you can check the status with the following command
systemctl status squid
you can manage the squid service with the following command.
systemctl start squid systemctl stop squid systemctl restart squid
- Enable squid service so it’s run automatically after reboot
systemctl enable squid
- If you want to disable the service then you can use this command
systemctl disable squid
- now we are going to edit squid.conf so first take a backup for security
cp -rp /etc/squid/squid.conf /etc/squid/squid.conf-bkp
- Open squid.conf file with your favorite editor
vim /etc/squid/squid.conf
- Edit http_port with your choice, the default port is 3128
http_port 31428

Keep http_access deny all as the final access rule. Never replace it with an unrestricted allow rule: that creates an open proxy. Allow only trusted client addresses and authenticated users before the final deny, retain Squid’s default unsafe-port restrictions, and restrict the listening port with your firewall. See Squid access-control documentation.
http_access deny all

Add Squid ACL
acl trusted_clients src <trusted-client-IP-or-CIDR>

:wq! (save file)
Securing user authorization
- Install necessary tools
apt install apache2-utils -y
- create user authantication with following command
htpasswd -c /etc/squid/passwords testsquid
here testsquid is a user and passwords is a file there stores user authantication
- now configure user details in squid.conf file
- open squid.conf file then add following lines
vim /etc/squid/squid.conf
auth_param basic program /usr/lib/squid/basic_ncsa_auth /etc/squid/passwords auth_param basic realm proxy acl authenticated proxy_auth REQUIRED # Keep the default Safe_ports and SSL_ports restrictions above these rules. http_access allow trusted_clients authenticated http_access deny all

- then save and close the file
:wq! (save file)
- sestart squid service
systemctl restart squid
- test your setup with following command
curl --proxy http://<your-proxy-IP>:31428 --proxy-user testsquid https://example.com
Curl prompts for the password rather than embedding it in shell history. Basic proxy authentication does not encrypt credentials between the client and an HTTP proxy; use a trusted private network or an encrypted tunnel. Confirm the helper path with dpkg -L squid | grep basic_ncsa_auth, validate with squid -k parse, and test that requests from untrusted addresses and without valid credentials are denied. See the official NCSA authentication example.

Client setup
Now you are going to setup squid client in browser
go to crome then click on three don in right corner

- Then go to Settings

- Goto System and click on open your computer’s settings

- Go to Manual proxy setup then enable Use a proxy server and fill your server ip and port then click on save bottun.

IN FIREFOX
- In the upper right corner, click on the three lines icon ☰ to open Firefox’s menu, then click on Settings

- Scroll down and go to Network Settings then click on Settings

- click on Manual proxy configuration and fill the server ip and proxy port and click on OK

Now your browser is configured with proxy server. If you want to verify, open google.com, type ‘what is my ip’ and you can see your configured ip.

