Skip to content

TechDirectArchive

Hands-on IT, Cloud, Security & DevOps Insights

  • Home
  • About
  • Advertise With US
  • Reviews
  • Contact
  • Toggle search form
Home » Linux » How to Set Up and Configure a Squid Proxy Server
  • images
    Fix the Synchronization service scheduler is suspended AWS/Azure/OpenShift
  • windows10
    How to Install and configure Active Directory Certificate Services Windows Server
  • windows 10 keyboard shortcut 1024x512 1
    How to create a Desktop shortcut in Windows Windows
  • windowsztrf
    Microsoft Desktop Optimization Pack [MDOP] at a glance Windows
  • Windows Server vNext
    What’s New? Install Windows Server 2025 on Beelink EQ12 PC Windows
  • Feature image msert tool
    How to remove malware using Microsoft Safety Scanner on Windows 10 and 11 Security | Vulnerability Scans and Assessment
  • fgbv
    Export and Import Scheduled Tasks in Windows Windows Server
  • Featured post
    Installing Windows Subsystem for Android (WSA) Windows

How to Set Up and Configure a Squid Proxy Server

Posted on 21/03/202213/07/2023 Raphael Gab-Momoh By Raphael Gab-Momoh 1 Comment on How to Set Up and Configure a Squid Proxy Server
squid-proxy-feature

A proxy server is server software that acts as a link between a client seeking a resource and the server that provides that resource in information systems. Squid is a Unix-based proxy server that caches Internet material closer to the requestor than the source. The software is capable of caching a wide range of web items, including those accessible through HTTP and FTP. You can check more here. squid-cache. This article will show you what Squid proxy is all about and how to set up and configure a squid proxy server.

Also, it will guide you on how to create a basic Squid forward proxy in the demo at the end of the article. Other guides can be found here: How to Install and Configure Nagios on Ubuntu/, How to install MariaDB on Ubuntu/ and What are the differences between dnf and apt package managers?/ and also How to install Apache Tomcat on Ubuntu.

How Caching Works: A resource from the origin server is requested by the website page.
- The system looks in the cache to determine if the resource has previously been cached.

If the resource has been cached, a cache hit response will be returned, and the resource will be supplied from the cache. Cache loss will occur if the resource is not cached, and the file will be accessed from its original source. The resource will be viewed until it expires, or the cache is removed after it has been cached.

Why should I Set Up Squid?

HTTP caches can aid with perceived latency, network consumption, and online application speed. Thus, you can use caches as a proxy filter, limiting access to specific websites or resources. There are two types of caches: forward and backward.

Types of Caches

Forward Cache: In a network, a forward cache helps to speed up HTTP access. When several browsers access the same cache, the material may be retrieved from the cache rather than requesting it from the original server. The following are examples of forward caches:

  • Squid
  • Tinyproxy
  • Apache.

Reverse Cache: A reverse cache reduces the apparent latency between an HTTP application server and any client. 

  • Squid
  • Nginx
  • Tinyproxy
  • Apache.

Proxy SSL

When a browser fetches an https:// URI, one of the following things happen:

  • A CONNECT method request is made to the proxy server, and traffic is transparently forwarded to the destination. Besides, the proxy has no ability to filter on URI, path, query string, or other information.
  • The browser directly connects to the HTTPS server, bypassing the proxy.
  • SslBump Peek and Splice – makes bumping decisions after the origin server is known.

Because the CONNECT method passes any TCP traffic, you should enable this option with care. It is possible to decrypt and monitor the SSL traffic using Squid. However, there are legal, ethical, and security concerns in doing so.

Cache Hierarchy

Cache hierarchies are an extension of the caching concept. Hence, working together, a group of cache servers can improve caching efficiency, route traffic to the optimal link, and accommodate a larger number of customers. There are two sorts of cache server hierarchy configurations that may be combined and matched.

Peer to Peer: Cache servers check with all or some of their peers to see whether they have cached material, and if they haven’t, the cache server requests the content.

Parent/Child: Cache servers query a parent server whether it has anything, and the parent retrieves it on the child’s behalf.

How to set up and configure Squid

The main squid configuration file, squid.conf, can be found in the following locations:

/etc/squid/squid.conf
/etc/squid3/squid.conf

Commonly configured options include:

  • http_port: Port to listen on for incoming proxy requests.
  • http_access: Allow or deny access to certain HTTP requests.
  • hierarchy_stoplist: Set of strings which disable the cache hierarchy settings.

Squid can also parse and check its syntax with a built-in syntax checker:

# squid -k parse

The -k switch takes the following options as well:

  • reconfigure: Reload the configuration file.
  • shutdown: Safe shutdown.
  • kill: Hard unclean shutdown.

Please consult man squid for more options and details.

Security Configuration

Access list begins with an aclname and acltype followed by:

  • type-specific argument(s), or
  • a quoted filename with one item per line.

Access Control Lists (ACL) format:

acl aclname acltype argument ...
acl aclname acltype "file" ...

To see the possible ACL types, review the “Access Controls in Squid” documentation. To enable a parent cache server, use the following configuration option:

cache_peer parent.example.com parent 3128 3130

You can enable a sibling peer cache server, use the following configuration option:

cache_peer childcache.example.com sibling 3128 3130

You can control access to the peer cache with the following option:

cache_peer_access <PEER_NAME> <allow|deny> <ACLNAME>

Access Control for Squid Set Up

Access control is one of the main reasons to use a proxy. In addition, the ACL system of Squid has options to control almost every aspect of an HTTP request. Access control can be restricted by time of day, by domain/URI, by the user (logging into proxy), and by content. Meanwhile, configuration files are processed sequentially.

To enable the ACL named hourlyworkers to only use the proxy during business hours, do:

acl workinghours time MTWHF 08:00-18:00
http_access allow hourlyworkers workinghours
http_access deny hourlyworkers

To restrict by a part of the URI, do:

acl banned_reddit url_regex ˆhttp://.*reddit.com/.*$
http_access deny banned_reddit

Allow only authenticated users to use the following configuration:

acl valid_users proxy_auth REQUIRED
http_access allow valid_users
http_access deny all

When building ACLs or configuration files for Squid, remember that the first match wins. Therefore, start your ACLs with the most specific options in the beginning.

Create a Basic squid Forward Proxy

Ascertain that squid is installed enabled

$apt install squid
How to setup and configure a Proxy Server-enable
apt install squid

Then, verify the default route by using the command below

$ ip route
How to setup and configure a Proxy Server-route
verify route

Furthermore, confirm the IP address by using the command below

$ip addr
-ipaddress
verify ip address

In addition, create an ACL for your network. Edit/etc/squid/squid. conf

#acl localnet src 192.168.125.160/24
acl-added
editing squid.conf file

Then, locate where you can insert your own rules as shown below in the screenshot below

How to setup and configure a Proxy Server-ur-rules
insert your own rules

Explicitly allow HTTP access for the newly created ACL

http_access allow localnet src 192.128.125.160/25
rule-added
create your own rules

Test the syntax of squid.conf

squid -k parse
test-squid-1
reconfiguring with squid -k parse

Start or restart the Squid daemon

systemctl  restart squid

Finally, test the proxy

by visiting any known website like CNN.com on your VM's browser

Visit a known non-existent URI (http://abcdcef.example.com). You should notice a squid error when u visit the non-existent page

Summary

In conclusion, Squid is a Unix-based proxy server that caches Internet material closer to the requestor than the source. By now, you should know how to set up and configure Squid proxy server. Bear in mind that It can be installed and configured by following the steps above.

Rate this post

Thank you for reading this post. Kindly share it with others.

  • Click to share on X (Opens in new window) X
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on Pinterest (Opens in new window) Pinterest
  • Click to share on Tumblr (Opens in new window) Tumblr
  • Click to share on Telegram (Opens in new window) Telegram
  • Click to share on WhatsApp (Opens in new window) WhatsApp
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to share on Mastodon (Opens in new window) Mastodon
  • Click to share on Bluesky (Opens in new window) Bluesky
  • Click to share on Threads (Opens in new window) Threads
  • Click to share on Nextdoor (Opens in new window) Nextdoor
Linux

Post navigation

Previous Post: How to Install and Configure Nagios on Ubuntu
Next Post: How to Configure Virtual Host for Apache HTTP Web Server to Host Several Domains on Ubuntu 20.04 LTS

Related Posts

  • sdf
    Creating an offline local repository in Linux Linux
  • sshfs
    Mounting remote directory using sshfs Linux
  • TERRAFORM ON LINUX FEATURE IMAGE
    How to Install Terraform on Linux Linux
  • screenshot 2020 04 23 at 00.30.09
    How to mount a USB Drive in Linux Linux
  • download
    Remove Packages from a Linux: Quick Guide Linux
  • images copy
    How to clean packages lying around in Linux Linux

More Related Articles

sdf Creating an offline local repository in Linux Linux
sshfs Mounting remote directory using sshfs Linux
TERRAFORM ON LINUX FEATURE IMAGE How to Install Terraform on Linux Linux
screenshot 2020 04 23 at 00.30.09 How to mount a USB Drive in Linux Linux
download Remove Packages from a Linux: Quick Guide Linux
images copy How to clean packages lying around in Linux Linux

Comment (1) on “How to Set Up and Configure a Squid Proxy Server”

  1. Avatar photo Rabbit Slayer says:
    04/08/2022 at 8:03 AM

    Syntax error correction:

    When allowing the ACL, do not specify the src ip:

    Explicitly allow HTTP access for the newly created ACL

    http_access allow localnet
    
    Log in to Reply

Leave a Reply Cancel reply

You must be logged in to post a comment.

Microsoft MVP

VEEAMLEGEND

vexpert-badge-stars-5

Virtual Background

GoogleNews

Categories

veeaam100

sysadmin top30a

  • images
    Fix the Synchronization service scheduler is suspended AWS/Azure/OpenShift
  • windows10
    How to Install and configure Active Directory Certificate Services Windows Server
  • windows 10 keyboard shortcut 1024x512 1
    How to create a Desktop shortcut in Windows Windows
  • windowsztrf
    Microsoft Desktop Optimization Pack [MDOP] at a glance Windows
  • Windows Server vNext
    What’s New? Install Windows Server 2025 on Beelink EQ12 PC Windows
  • Feature image msert tool
    How to remove malware using Microsoft Safety Scanner on Windows 10 and 11 Security | Vulnerability Scans and Assessment
  • fgbv
    Export and Import Scheduled Tasks in Windows Windows Server
  • Featured post
    Installing Windows Subsystem for Android (WSA) Windows

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 1,839 other subscribers
  • RSS - Posts
  • RSS - Comments
  • About
  • Authors
  • Write for us
  • Advertise with us
  • General Terms and Conditions
  • Privacy policy
  • Feedly
  • Telegram
  • Youtube
  • Facebook
  • Instagram
  • LinkedIn
  • Tumblr
  • Pinterest
  • Twitter
  • mastodon

Tags

AWS Azure Bitlocker Microsoft Windows PowerShell WDS Windows 10 Windows 11 Windows Deployment Services Windows Server 2016

Copyright © 2025 TechDirectArchive

 

Loading Comments...
 

You must be logged in to post a comment.