Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Squid Proxy Server 3.1: Beginner's Guide
Squid Proxy Server 3.1: Beginner's Guide

Squid Proxy Server 3.1: Beginner's Guide: Reduce bandwidth use and deliver your most frequently requested web pages more quickly with Squid Proxy Server. This guide will introduce you to the fundamentals of the caching system and help you get the most from Squid.

eBook
zł39.99 zł158.99
Paperback
zł197.99
Subscription
Free Trial

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Squid Proxy Server 3.1: Beginner's Guide

Chapter 2. Configuring Squid

We have learned about compiling Squid source code and installing Squid from a source and binary package. In this chapter, we are going to learn to configure Squid according to the requirements of a given network. We will learn about the general syntax used for a Squid configuration file and then we will move on to exploring the different options available to fine tune Squid. There will be a few options which we will only cover briefly but there will be chapters dedicated to them while we will explore other options in detail.

In this chapter, we will cover the following:

  • Quick exposure to Squid

  • Syntax of the configuration file

  • HTTP port, the most important configuration directive

  • Access Control Lists (ACLs)

  • Controlling access to various components of Squid

  • Cache peers or neighbors

  • Caching the web documents in the main memory and hard disk

  • Tuning Squid to enhance bandwidth savings and reduce latency

  • Modifying the HTTP headers accompanied with requests and responses

  • Configuring...

Quick start


Before we explore a configuration file in detail, let's have a look at the minimal configuration that you will need to get started. Get ready with the configuration file located at /opt/squid/etc/squid.conf, as we are going to make the changes and additions necessary to quickly set up a minimal proxy server.

cache_dir ufs /opt/squid/var/cache/ 500 16 256
acl my_machine src 192.0.2.21 # Replace with your IP address
http_access allow my_machine

We should add the previous lines at the top of our current configuration file (ensuring that we change the IP address accordingly). Now, we need to create the cache directories. We can do that by using the following command:

$ /opt/squid/sbin/squid -z

We are now ready to run our proxy server, and this can be done by running the following command:

$ /opt/squid/sbin/squid

Squid will start listening on port 3128 (default) on all network interfaces on our machine. Now we can configure our browser to use Squid as an HTTP proxy server with the host...

Syntax of the configuration file


Squid's configuration file can normally be found at /etc/squid/squid.conf, /usr/local/squid/etc/squid.conf, or ${prefix}/etc/squid.conf where ${prefix} is the value passed to the --prefix option, which is passed to the configure command before compiling Squid.

In the newer versions of Squid, a documented version of squid.conf, known as squid.conf.documented, can be found along side squid.conf. In this chapter, we'll cover some of the import directives available in the configuration file. For a detailed description of all the directives used in the configuration file, please check http://www.squid-cache.org/Doc/config/.

The syntax for Squid's documented configuration file is similar to many other programs for Linux/Unix. Generally, there are a few lines of comments containing useful related documentation before every directive used in the configuration file. This makes it easier to understand and configure directives, even for people who are not familiar with...

HTTP port


This directive is used to specify the port where Squid will listen for client connections. The default behavior is to listen on port 3128 on all the available interfaces on a machine.

Time for action – setting the HTTP port


Now, we'll see the various ways to set the HTTP port in the squid.conf file:

  • In its simplest form, we just specify the port on which we want Squid to listen:

    http_port 8080
  • We can also specify the IP address and port combination on which we want Squid to listen. We normally use this approach when we have multiple interfaces on our machine and we want Squid to listen only on the interface connected to local area network (LAN):

    http_port 192.0.2.25:3128

    This will instruct Squid to listen on port 3128 on the interface with the IP address as 192.0.2.25.

  • Another form in which we can specify http_port is by using hostname and port combination:

    http_port myproxy.example.com:8080

    The hostname will be translated to an IP address by Squid and then Squid will listen on port 8080 on that particular IP address.

  • Another aspect of this directive is that, it can take multiple values on separate lines. Let's see what the following lines will do:

    http_port 192.0.2.25:8080
    http_port...

Access control lists


Access Control Lists (ACLs) are the base elements for access control and are normally used in combination with other directives such as http_access, icp_access, and so on, to control access to various Squid components and web resources. ACLs identify a web transaction and then directives such as http_access, cache, and then decides whether the transaction should be allowed or not. Also, we should note that the directives related to accessing resources generally end with _access.

Every access control list definition must have a name and type, followed by the values for that particular ACL type:

acl ACL_NAME ACL_TYPE value
acl ACL_NAME ACL_TYPE "/path/to/filename"

The values for any ACL name can either be specified directly after ACL_TYPE or Squid can read them from a separate file. Here we should note that the values in the file should be written as one value per line.

Time for action – constructing simple ACLs


Let's construct an access control list for the domain name example.com:

acl example_site dstdomain example.com

In this code, example_site is the name of the ACL with type dstdomain, which reflects that the value, example.com, is the domain name.

Now if we want to construct an access control list which can cover a lot of example websites, we have the following three possible ways of doing it:

  1. Values on a single line: We can specify all the possible values on a single line:

    acl example_sites dstdomain example.com example.net example.org

    This works fine as long as there are only a few values.

  2. Values on multiple lines: In case the list of values that we want to specify grows significantly, we can split the list and pass values on multiple lines:

    acl example_sites dstdomain example.com example.net
    acl example_sites dstdomain example.org
  3. Values from a file: If case the number of values we want to specify is quite large, we can put them in a dedicated file and...

Left arrow icon Right arrow icon

Key benefits

  • Get the most out of your network connection by customizing Squid's access control lists and helpers
  • Set up and configure Squid to get your website working quicker and more efficiently
  • No previous knowledge of Squid or proxy servers is required
  • Part of Packt's Beginner's Guide series: lots of practical, easy-to-follow examples accompanied by screenshots

Description

Squid Proxy Server enables you to cache your web content and return it quickly on subsequent requests. System administrators often struggle with delays and too much bandwidth being used, but Squid solves these problems by handling requests locally. By deploying Squid in accelerator mode, requests are handled faster than on normal web servers making your site perform quicker than everyone else's! Squid Proxy Server 3.1 Beginner's Guide will help you to install and configure Squid so that it is optimized to enhance the performance of your network. The Squid Proxy Server reduces the amount of effort that you will have to put in, saving your time to get the most out of your network. Whether you only run one site, or are in charge of a whole network, Squid is an invaluable tool that improves performance immeasurably. Caching and performance optimization usually requires a lot of work on the developer's part, but Squid does all that for you. This book will show you how to get the most out of Squid by customizing it for your network. You will learn about the different configuration options available and the transparent and accelerated modes that enable you to focus on particular areas of your network. Applying proxy servers to large networks can be a lot of work as you have to decide where to place restrictions and who should have access, but the straightforward examples in this book will guide you through step by step so that you will have a proxy server that covers all areas of your network by the time you finish the book.

Who is this book for?

If you are a Linux or Unix system administrator and you want to enhance the performance of your network or you are a web developer and want to enhance the performance of your website, this book is for you. You are expected to have some basic knowledge of networking concepts, but may not have used caching systems or proxy servers before now.

What you will learn

  • Discover which configuration option would best suit your network
  • Gain better control over Squid with command-line options that help you to debug Squid
  • Devise an Access Control List (ACL) to decide which users are granted access to different ports
  • Understand logfiles and log format and how to customize them to suit your needs
  • Learn about Squid s Cache Manager web interface so that you can monitor your traffic in real time to prevent any problems before they happen
  • Implement a cache hierarchy to use in a large network
  • Use Squid in Accelerator Mode to quickly boost the performance of a very slow website
  • Write your own URL rewriters to customize the behavior of Squid
  • Learn how to troubleshoot Squid

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Feb 21, 2011
Length: 332 pages
Edition : 1st
Language : English
ISBN-13 : 9781849513906
Languages :
Concepts :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Feb 21, 2011
Length: 332 pages
Edition : 1st
Language : English
ISBN-13 : 9781849513906
Languages :
Concepts :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just zł20 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just zł20 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 662.97
Advanced Penetration Testing for Highly-Secured Environments: The Ultimate Security Guide
zł266.99
FreeRADIUS Beginner's Guide
zł197.99
Squid Proxy Server 3.1: Beginner's Guide
zł197.99
Total 662.97 Stars icon
Banner background image

Table of Contents

12 Chapters
Getting Started with Squid Chevron down icon Chevron up icon
Configuring Squid Chevron down icon Chevron up icon
Running Squid Chevron down icon Chevron up icon
Getting Started with Squid's Powerful ACLs and Access Rules Chevron down icon Chevron up icon
Understanding Log Files and Log Formats Chevron down icon Chevron up icon
Managing Squid and Monitoring Traffic Chevron down icon Chevron up icon
Protecting your Squid Proxy Server with Authentication Chevron down icon Chevron up icon
Building a Hierarchy of Squid Caches Chevron down icon Chevron up icon
Squid in Reverse Proxy Mode Chevron down icon Chevron up icon
Squid in Intercept Mode Chevron down icon Chevron up icon
Writing URL Redirectors and Rewriters Chevron down icon Chevron up icon
Troubleshooting Squid Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.7
(13 Ratings)
5 star 69.2%
4 star 30.8%
3 star 0%
2 star 0%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




Ryan F. Jun 19, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Amazingly helpful book for squid. The only resource I need for my servers! Thanks!
Amazon Verified review Amazon
J. Ritter Jan 19, 2013
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Squid is wonderful software and has gone through some big and important changes in 3.0 and 3.1. I used this book to create custom built transparent-proxy (TPROXY) squid servers that interact with Cisco routers via WCCP v2.
Amazon Verified review Amazon
Norbert Wrann Nov 17, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Lockerer Schreibstiel, der leicht und verständlich den Squid Proxy erklärt.Mit wenigen Handgriffen ein laufendes System einzurichten ist nicht schwierig.Das Buch kann man nicht nur Experten, sondern auch Anfängern empfehlen.
Amazon Verified review Amazon
comicmonster Aug 17, 2013
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Good guide for newbies getting into proxy configurations. Takes you through the whole process with in depth knowledge and insight into what goes behind the scenes.
Amazon Verified review Amazon
pat13b Sep 17, 2020
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Great Info even if its not the latest version. Was able to get some really good info from this book.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.