Personal tools
You are here: Home Documentation Production Configuration Squid configuration file

Squid configuration file

by T. Kim Nguyen last modified Nov 03, 2011 12:27 AM
— filed under:

a sample squid.conf

# This configuration file requires squid 2.6+.  It is untested with squid 3.x.                                                                                                                                                                                                                                                                                                                                   

# Present a special hostname in error messages, etc                                                                                                                                                                                                                                                                                                                                                              
visible_hostname ourdomain.edu

# Cache manager email                                                                                                                                                                                                                                                                                                                                                                                            
cache_mgr webmaster@ourdomain.edu

# If starting Squid as root, this will change the effective/real UID/GID                                                                                                                                                                                                                                                                                                                                         
# to the user specified below.  The default is to change the UID to nobody.                                                                                                                                                                                                                                                                                                                                      
cache_effective_user squid
cache_effective_group squid

# The port on which to listen:                                                                                                                                                                                                                                                                                                                                                                                   
#   "vhost" turns on accelerator mode using Host header for virtual domain support                                                                                                                                                                                                                                                                                                                               
#   "defaultsite" defines the default domain to use for Host header                                                                                                                                                                                                                                                                                                                                              
http_port 3128 vhost defaultsite=www.ourdomain.edu

## Squid log files                                                                                                                                                                                                                                                                                                                                                                                               
# cache_access_log /access.log                                                                                                                                                                                                                                                                                                                                                                                   
# cache_log /cache.log                                                                                                                                                                                                                                                                                                                                                                                           
# cache_store_log /store.log                                                                                                                                                                                                                                                                                                                                                                                     
## Turn off logging...                                                                                                                                                                                                                                                                                                                                                                                           
#cache_store_log none                                                                                                                                                                                                                                                                                                                                                                                            
#cache_log /dev/null                                                                                                                                                                                                                                                                                                                                                                                             
logfile_rotate 0   # avoid accidentally rotating /dev/null                                                                                                                                                                                                                                                                                                                                                       

cache_access_log /var/log/squid/access.log

# Set cache directory and size (1000 MB) - be sure to set the cache size to                                                                                                                                                                                                                                                                                                                                      
# about 10% less than the physical space available to leave room for squid's                                                                                                                                                                                                                                                                                                                                     
# swap files and other temp files                                                                                                                                                                                                                                                                                                                                                                                
cache_dir ufs /var/spool/squid 10000 16 256

# Amount of memory used for recent objects (default: 8 MB)                                                                                                                                                                                                                                                                                                                                                       
cache_mem 1024 MB

# Max cached-on-disk object size (default: 4096 KB)                                                                                                                                                                                                                                                                                                                                                              
maximum_object_size 10 MB

# Max cached-in-memory object size (default: 8 KB)                                                                                                                                                                                                                                                                                                                                                               
maximum_object_size_in_memory 1 MB

# Squid requires a default 'all' acl                                                                                                                                                                                                                                                                                                                                                                             
acl all src 0.0.0.0/0.0.0.0

# Purge access - zope servers can purge but nobody else                                                                                                                                                                                                                                                                                                                                                          
# (works best if Zope and Apache are on different IPs)                                                                                                                                                                                                                                                                                                                                                           
acl zope_servers src 127.0.0.1 123.456.789.012 123.456.789.013
acl purge method PURGE
http_access allow zope_servers purge
http_access deny purge


# Cache Peers                                                                                                                                                                                                                                                                                                                                                                                                    
cache_peer ploneserver1.bunker.ourdomain.edu parent 8000 0 no-query originserver name=plone323
cache_peer ploneserver1.bunker.ourdomain.edu parent 12000 0 no-query originserver name=plone401
cache_peer ploneserver1.bunker.ourdomain.edu parent 15080 0 no-query originserver name=plone41
cache_peer ploneserver1.bunker.ourdomain.edu parent 16000 0 no-query originserver name=plonelibrary

# Cache Peer Access                                                                                                                                                                                                                                                                                                                                                                                              
acl plone323sites urlpath_regex "/etc/squid/plone323sites.acl"
acl plone401sites urlpath_regex "/etc/squid/plone401sites.acl"
acl plone41sites urlpath_regex "/etc/squid/plone41sites.acl"
acl plonelibrarysites urlpath_regex "/etc/squid/plonelibrarysites.acl"

cache_peer_access plone323 allow plone323sites
cache_peer_access plone323 deny all

cache_peer_access plone401 allow plone401sites
cache_peer_access plone401 deny all

cache_peer_access plone41 allow plone41sites
cache_peer_access plone41 deny all

cache_peer_access plonelibrary allow plonelibrarysites
cache_peer_access plonelibrary deny all

# SPECIFY WHAT REQUESTS SQUID SHOULD CACHE                                                                                                                                                                                                                                                                                                                                                                       
# Control what squid caches.  We want to have squid handle content that is not                                                                                                                                                                                                                                                                                                                                   
# personalized and that does not require any kind of authorization.                                                                                                                                                                                                                                                                                                                                              



#  Prevent squid from caching an item that is the result of a POST                                                                                                                                                                                                                                                                                                                                               
acl post_requests method POST
cache deny post_requests

#3) Prevent squid from caching requests from users authenticated via cookies                                                                                                                                                                                                                                                                                                                                     
acl ac_cookie req_header Cookie -i __ac=
acl zope_cookie req_header Cookie -i _ZopeId=
cache deny ac_cookie
cache deny zope_cookie

negative_ttl 1 minute
cache_vary on
max_filedesc 4096
 
Document Actions
  • Print this
  • Bookmarks