How to set up a Squid Proxy on Ubuntu 20.04
Squid Proxy is a Linux-based application. This is a full-featured caching proxy supporting popular network protocols like HTTP, HTTPS, FTP, and more.
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
- Edit http_port with your choice, the default port is 3128
Then search “http_access deny all” words for doings depends to expected result. If you want to everyone access just set this to “allow all“.
http_access deny all
Add Squid ACL
acl localnet src <server ip>
: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
auth_param basic program /usr/lib/squid3/basic_ncsa_auth /etc/squid/passwords auth_param basic realm proxy acl authenticated proxy_auth REQUIRED http_access allow authenticated
- then save and close the file
:wq! (save file)
- sestart squid service
systemctl restart squid
- test your setup with following command
curl -v -x http://testsquid:<squid-password>@<your-ip>:31428 https://google.com
Now you can see you are connected properly
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 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.