Squid is a caching and forwarding web proxy server for Linux-based operating systems.
It supports the HTTP, HTTPS, and FTP protocols and is used to improve web server performance by caching repeated requests. It is also used to control Internet access and protect your network from unknown traffic.
Generally, a proxy server is placed between the client and the Internet. All requests from the client machine are routed through a proxy server.
Features
Squid has the following main features:
- Speeds up web server performance.
- Shares the Internet connection on the local network.
- Filters Internet traffic according to rules.
- Hides your real IP address.
In this tutorial we will show you how to configure a proxy server with Squid on Debian 10.
Requirements
To follow this tutorial, you will need:
- A system running Debian 10.
- A desktop system with Firefox installed.
OK, let's get started!
Install Squid Proxy
By default, the Squid package is included in the default Debian 10 repository. You can install it by running the following command:
# apt install squid -yOnce Squid is installed, start the Squid service and enable it to start when the system reboots:
# systemctl start squid
# systemctl enable squidYou can check the status of Squid with the following command:
# systemctl status squidYou should get the following output:
● squid.service - Squid Web Proxy Server
Loaded: loaded (/lib/systemd/system/squid.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2021-01-20 05:05:54 UTC; 40s ago
Docs: man:squid(8)
Main PID: 1343 (squid)
Tasks: 4 (limit: 2359)
Memory: 16.1M
CGroup: /system.slice/squid.service
├─1343 /usr/sbin/squid -sYC
├─1345 (squid-1) --kid squid-1 -sYC
├─1346 (logfile-daemon) /var/log/squid/access.log
└─1362 (pinger)
Jan 20 05:05:54 debian10 squid[1345]: Using Least Load store dir selection
Jan 20 05:05:54 debian10 squid[1345]: Set Current Directory to /var/spool/squid
Jan 20 05:05:54 debian10 squid[1345]: Finished loading MIME types and icons.
Jan 20 05:05:54 debian10 systemd[1]: /lib/systemd/system/squid.service:7: PIDFile= references path below legacy directory /var/run/, updating /
Jan 20 05:05:54 debian10 squid[1345]: HTCP Disabled.
Jan 20 05:05:54 debian10 squid[1345]: Pinger socket opened on FD 14
Jan 20 05:05:54 debian10 squid[1345]: Squid plugin modules loaded: 0
Jan 20 05:05:54 debian10 squid[1345]: Adaptation support is off.
Jan 20 05:05:54 debian10 squid[1345]: Accepting HTTP Socket connections at local=[::]:3128 remote=[::] FD 12 flags=9
Jan 20 05:05:55 debian10 squid[1345]: storeLateRelease: released 0 objects
Change the Default Squid Port
By default, Squid listens on port 3128. You can verify this with the following command:
# ss -antpl | grep 3128 You should see the following output; if you do not, it is most likely because the port is closed in the Firewall:
LISTEN 0 128 *:3128 *:* users: ("squid",pid=1345,fd=12))
You can change the default Squid port by editing the file /etc/squid/squid.conf.
# nano /etc/squid/squid.confChange the following line to use the desired port:
http_port 3128
Save and close the file, then restart the Squid service to apply the changes:
# systemctl restart squidWarning
Remember that you must open port 3128 in the server firewall.
Configure Squid to Allow All Traffic
By default, the Squid proxy server rejects all incoming traffic, so you will need to allow all traffic on the proxy server.
To do this, you need to edit the main Squid configuration file:
# nano /etc/squid/squid.confComment out the line http_access deny all and add http_access allow all as shown below:
http_access allow all
http_access deny allSave and close the file, then restart the Squid service to apply the changes:
# systemctl restart squidBlocking Some Websites
If you are using the Squid proxy server on your internal network to share Internet access, it is a good idea to block some websites.
You can do this by editing the main Squid configuration file:
nano /etc/squid/squid.conf
Add the following line just above "allow all rules" to block the websites facebook.com and yahoo.com:
acl blacklist1 dstdomain facebook.com
acl blacklist2dstdomain yahoo.com
http_access deny blacklist1
http_access deny blacklist2Save and close the file, then restart the Squid service to apply the changes:
# systemctl restart squidConfigure the Client Browser to Use a Proxy
Next, you will need to configure the Firefox web browser on each client PC to use the Squid proxy server.
Follow the steps below to configure the proxy in the Firefox web browser:
Step 1: open the Firefox web browser. In the upper-right corner, click the icon "hamburger" => Preferencias. You should see the following screen:
Step 2: scroll down to the section "Configuración de red" and click "Configuración". You should see the following screen:
Step 3: select "Configuración manual del proxy" and provide your proxy server's IP and port, then select the checkbox "Usar este servidor proxy para todos los protocolos" and click the button "OK" to save the settings.
Perform the steps above in all client browsers.
Test the Squid Proxy
At this point, your web browser is configured to use the Squid proxy server.
Now open your web browser and access the URL https://whatismyipaddress.com/. You should see your proxy server's IP address on the following screen:
Now try accessing http://facebook.com and http://yahoo.com/ in your web browser. You should get the access denied error as shown below:
Remember, if you have questions about this or any other issue related to your servers on Clouding, feel free to write to soporte@clouding.io We are here for whatever you need. Just ask us!