Linux Harbour

Technology News of Linux & Open Source


How to setup Squid HTTP Proxy on Ubuntu 22.04 LTS

Squid is a popular open-source caching proxy server that primarily operates as an HTTP proxy. It acts as an intermediary between clients and web servers, allowing clients to make requests for web content, and caching frequently accessed content to improve performance and reduce bandwidth usage.

In some of our Python or backend API development projects for our clients, it is required to connect 3rd party API systems with fixed IP addresses for security measures. Nowadays we deploy our Python codes or backend codes to cloud systems which launch on demand with dynamic IP addresses. Squid HTTP Proxy is set up with a fixed IP address to serve this purpose.

Installation of Squid HTTP Proxy on Ubuntu 22.04 LTS

After we install a new Ubuntu 22.04 LTS on the cloud platform, we update its software package database to the latest, and then upgrade some installed packages to their latest versions. We Install Squid and net-tools after package upgrades.

apt update -y
apt upgrade -y
apt install squid net-tools -y

We backup the original Squid config file.

cp /etc/squid/squid.conf /etc/squid/squid.conf.original

Then we add the following lines to the Squid config file /etc/squid/squid.conf

dns_v4_first on
acl linuxharbour_api_servers src ${IP_ADDRESS_OF_OUR_API_SERVERS}/24
http_access allow linuxharbour_api_servers

We restart the Squid HTTP proxy service after we modified the config file.

systemctl restart squid.service

Key Features of Squid HTTP Proxy

Here are some key features and functionalities of Squid HTTP proxy:

  1. Caching: Squid caches web content, such as HTML pages, images, and other media files, locally on the server. When clients request the same content again, Squid can serve it from its cache instead of fetching it from the web server, resulting in faster response times and reduced network traffic.
  2. Proxying: Squid acts as an intermediary between clients and web servers. Clients send their requests to Squid, which then forwards those requests to the appropriate web servers on behalf of the clients. This can help improve security, as the clients’ IP addresses can be masked, and provide additional control and monitoring capabilities.
  3. Access Control: Squid allows administrators to configure various access control mechanisms to restrict or control client access to certain websites or content. Access control can be based on IP addresses, domain names, authentication, or other rules defined by the administrator.
  4. Content Filtering: Squid can be configured to filter web content based on predefined policies. This includes blocking access to specific websites or categories of websites (such as adult content or social media). Content filtering helps enforce internet usage policies and enhance network security.
  5. Load Balancing: Squid supports load balancing across multiple web servers, distributing client requests among them to optimize performance and handle higher traffic loads. This can improve the availability and scalability of web applications.
  6. Transparent Proxy: Squid can be configured as a transparent proxy, where client requests are automatically intercepted and redirected to the proxy server without requiring any additional client-side configuration. This allows for easier integration into existing network infrastructures.

Squid is highly customizable and extensible, with a wide range of configuration options and support for various plugins and add-ons. It is widely used in environments where caching, content filtering, and proxying capabilities are required, such as corporate networks, ISPs, educational institutions, and content delivery networks (CDNs).

Overall, Squid HTTP proxy provides powerful caching and proxying capabilities, helping to optimize web traffic, improve performance, and enhance security in network environments. Its flexibility and open-source nature have contributed to its popularity and adoption by many organizations worldwide.

Sammy Fung

Sammy is the founder of the Linux Harbour.