How to install and configure a Squid proxy server on Ubuntu

Last update: 04/10/2024
Squid Proxy Server on Ubuntu

Squid is one of the world's most popular proxy servers. It's free to download, easy to install, and can be deployed on any Linux distribution . Here's how to install and configure a Squid proxy server on Ubuntu.

Steps for Install and configure a Squid proxy server on Ubuntu

A proxy server is a very useful tool for the web. It is commonly used in computer networks to protect the network from attacks, to filter malicious web content, pages requested by local users, and to speed up the delivery of web pages and web content by caching (saving) web pages, documents, and media.

You may also be interested in: How to Fix the err_proxy_connection_failed Error. 11 Solutions

Proxies are typically deployed on private LANs to filter, protect, and cache content requested by users on that network, this is called a "proxy" or "transparent proxy." Proxies can also be deployed on remote third-party target web servers to protect those servers by filtering requests, speeding up web page delivery, and caching frequently requested files.

sudo apt-get update

sudo apt-get install squid squid-common

  • Step 2: Ways to start and stop Squid:

sudo service squid start

sudo /usr/sbin/squid sudo pkill -9 squid (force kill a process)

  • Step 3:: Configuring Squid: Go to the Squid folder to find the configuration file:

squid.conf

cd /etc/squid

  • Step 4: Make a backup of your file:

squid.conf

sudo cp squid.conf squid.conf.bak

  • Step 5: For testing purposes, open Firefox and configure it to send web requests to the Squid proxy server (you can find its IP address using the ifconfig command).
  • Step 6: Open Firefox: Edit > Preferences, Advanced > Network tab > Connection Settings: Manual proxy settings: HTTP proxy: your IP address or loopback 127.0.0.1, port: 3128
  • Step 7:: Click OK and Close
  • Now, if you try to visit a site like Google, you should see an error: Access Denied from Squid. This means that Squid is actively filtering traffic.
  • Step 8: Next, you need to configure Squid to allow web traffic through the proxy server. Open squid.conf in a text editor:
  Apps included in Microsoft 365 Companions: Complete guide and availability

sudo nano squid.conf

  • Step 9: Change your Squid proxy name (line 3399). TAG:

visible_hostname

visible_host_name YourNameProxyServer

  • Step 10: You can configure access rules for your Squid proxy (lines 331-831 are for access control). Note that lines 606-630 define the LANs and ports (services) used. Active configuration lines are lines that are not commented out, i.e. they do not start with a # sign.
  • Step 11: To re-enable web access, uncomment line 676 http_access allow localnet.
  • Step 12: To ensure that networking is now working, save the changes to the squid.conf file and restart the Squid server: sudo service squid restart
  • Step 13: Refresh your Firefox browser and your home page should be visible.
  • Step 14: You can now practice writing your own ACL (access list) in the squid.conf file to block specific domains and websites.
  • Step 15: You can write your own ACL at the end of the acl line around line 631. From a blank line, type the following lines to check for domain locking:

acl blocked_websites dstdomain .msn.com .yahoo.comhttp_access deny blocked_websites

  • Step 16:: Restart the Squid server and check if Squid is denying access to your blocked domains/websites in Firefox.

Types of proxy servers

A proxy (translated from English as a trusted person) is an intermediary web server used between the user and the final server. The client's web browser is configured to specify the proxy server's IP address.

The client can bypass the proxy by deleting or changing the proxy address settings. An administrator can prevent this by creating a Group Policy object in Active Directory that blocks access to the web browser settings. A proxy server can also function as a caching server.

  • Transparent proxy server: The router sends all traffic through specific ports to a transparent proxy, so clients cannot bypass the proxy. A transparent proxy can also function as a caching server.
  • Reverse proxy (caching): A reverse proxy or caching server is placed in front of the web server to speed up the delivery of frequently requested pages and protect the web server by creating a layer of separation and redundancy.

You might also be interested in: How to Download Discord for Ubuntu – Tutorial

 What is Squid – proxy server?

Squid is a full-featured caching proxy server application for HTTP, FTP, and other popular network protocols. It is capable of caching and proxying SSL requests and caching DNS lookup results, as well as transparent caching.

  5 Best Programs for Making Organizational Charts

The application also supports a wide range of caching protocols such as ICP (Internet Caching Protocol), HTCP (Hypertext Caching Protocol), CARP (Routing Caching Protocol), and WCCP (Content Redirection Caching Protocol).

Squid Proxy is an excellent solution for broad caching and proxy server requirements that scales from the regional office to the corporate network by providing extensible shared access control and a critical monitoring mechanism via SNMP.

When choosing a computer system to use as a Squid proxy or cache server , make sure your system has enough RAM, as Squid maintains a cache in memory to improve performance.

To install Squid Server, in Terminal, you must enter the following command: sudo apt-get install squid And to configure it, edit the directives contained in the configuration file /etc/squid/squid.conf.

Now that you know how to configure a Squid proxy server on Ubuntu , you shouldn't miss the opportunity to do so and enjoy the benefits it offers by storing the web pages that users visit and sending them to other users without needing to access the Internet again.

Javier Chirinos

Javier Chirinos

My name is Javier Chirinos and I am passionate about technology. Ever since I can remember, I have been interested in computers and video games, and that passion has turned into a job.

I have been publishing about technology and gadgets on the Internet for over 15 years, especially in mundobytes.com

I am also an expert in online communication and marketing, and I have knowledge of WordPress development.