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
R$49.99 R$218.99
Paperback
R$272.99
Subscription
Free Trial
Renews at R$50p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

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 : 9781849513913
Languages :
Concepts :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

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

Packt Subscriptions

See our plans and pricing
Modal Close icon
R$50 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
R$500 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 R$25 each
Feature tick icon Exclusive print discounts
R$800 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 R$25 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total R$ 913.97
Advanced Penetration Testing for Highly-Secured Environments: The Ultimate Security Guide
R$367.99
FreeRADIUS Beginner's Guide
R$272.99
Squid Proxy Server 3.1: Beginner's Guide
R$272.99
Total R$ 913.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

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.