Quid cache (squid) is a popular free software (GNU General Public License) proxy server and Web cache server. Squid has a wide range of uses, from caching related requests as Web server cache servers to increasing the speed of Web servers, to sharing network resources for a group of people and caching the World Wide Web, domain name systems and other network searches, to help network security by filtering traffic, to LAN through proxy Internet. Squid is primarily designed to run on Unix-type systems, let's look at the SQUID3 (high hit Rate) cache server Configuration tutorial.
Today to my varnish under a small stress test, 40s 8000 concurrency, no failure, an estimate can also withstand greater concurrency, not to mention varnish, I recently found a high-hit squid configuration file, of course, is squid3.0 configuration file, There is a need to copy back to their own change.
System: CentOS 5.x
Required Software: squid-3.0.stable25.tar.gz
1. Download Squid
| The code is as follows |
|
wget http://www.squid-cache.org/Versions/v3/3.0/squid-3.0.STABLE25.tar.gz Tar zxf squid-3.0.stable25.tar.gz && CD Squid-3.0.stable25 |
2. Compiling squid
| code as follows |
  |
| ./configure--prefix=/usr/local/squid --enable-async-io=100 --with-pthreads --enable-storeio= "Aufs,diskd,ufs"   --enable-removal-policies= "Heap, LRU "  --enable-icmp --enable-delay-pools --enable-useragent-log -- enable-referer-log --enable-kill-parent-hack --enable-arp-acl -- enable-default-err-language=simplify_chinese --enable-err-languages= "Simplify_chinese 中文版" --disable-poll --disable-wccp --disable-wccpv2 --disable-ident-lookups --disable-internal-dns --enable-basic-auth-helpers= "NCSA"   --enable-stacktrace - -with-large-files --disable-mempools --with-filedescriptors=65536 --enable-ssl &NBSP --enable-x-accelerator-var Make do install make Install-pinger |
3. Configure Squid
| The code is as follows |
|
Cp/usr/local/squid/etc/squid.conf/usr/local/squid/etc/squid.conf.old >/usr/local/squid/etc/squid.conf Ln-s/usr/local/squid/etc/squid.conf/etc/squid.conf |
Contents of squid.conf:
| The code is as follows |
|
| #accel Listen Port Http_port Accel Vhost Vport #accel Domain Cache_peer xx.xx.xx.xx Parent 0 no-query originserver no-digest name=a Cache_peer_domain a www.111cn.net
#acl ACL manager Proto Cache_object ACL localhost src 127.0.0.1/255.255.255.255 ACL ssl_ports Port 443 563 ACL safe_ports Port # http ACL safe_ports Port 8080 ACL lansrc src All ACL LANDST DST All ACL LANDSTDM Dstdomain www.111cn.net
ACL Connect method Connect Http_access allow manager localhost Http_access Deny Manager Http_access Deny! Safe_ports Http_access Deny CONNECT! Ssl_ports Http_access Allow LANSRC Http_access Allow LANDST Http_access Allow LANDSTDM Http_access Deny All
#base Visible_hostname www.111cn.net Cache_mgr rocdk890@gmail.com Cache_effective_user Squid Cache_effective_group Squid
Error_directory/usr/local/squid/share/errors/simplify_chinese Icon_directory/usr/local/squid/share/icons Mime_table/usr/local/squid/etc/mime.conf
Cache_replacement_policy LRU #cache_dir Cache_dir Aufs/var/cache1 32768 64 64 Cache_dir Aufs/var/cache2 32768 64 64 Cache_mem 2048 MB Max_open_disk_fds 0 #maximum_object_size KB #maximum_object_size_in_memory KB Maximum_object_size MB Maximum_object_size_in_memory 8 MB
#keepalived Client_persistent_connections off Server_persistent_connections on #persistent_request_timeout seconds
#memory_pools on #memory_pools_limit MB
Forwarded_for on Log_icp_queries off
Via off Httpd_suppress_version_string off
Ie_refresh off Tcp_recv_bufsize KB
#acl webservices rep_header server-i ^linuxtonews ^apache ^nginx #broken_vary_encoding Allow WebServices
#hidden The squid header #reply_header_access Server deny all #reply_header_access X-cache deny all #reply_header_access Warning deny all #reply_header_access Expires deny all #reply_header_access Cache-control deny all #reply_header_access Age Deny all #reply_header_access all deny all Ipcache_size 1024 Ipcache_low 90 Ipcache_high 95
Memory_replacement_policy LRU
Hosts_file/etc/hosts Request_header_max_size KB
#deny Cache Hierarchy_stoplist cgi-bin? php ACL QUERY urlpath_regex cgi-bin?. php Cache Deny QUERY
#request_body_max_size 0 KB
Refresh_pattern ^ftp:60 20% 10080 Refresh_pattern ^gopher:60 0% 1440 Refresh_pattern. 0 20% 1440 Refresh_pattern-i. css$ 50% 2880 reload-into-ims Refresh_pattern-i. js$ 1440 50% 2880 reload-into-ims Refresh_pattern-i. html$ 720 50% 1440 Reload-into-ims Refresh_pattern-i. jpg$ 1440 90% 2880 ignore-reload Refresh_pattern-i. gif$ 1440 90% 2880 ignore-reload Refresh_pattern-i. swf$ 1440 90% 2880 ignore-reload Refresh_pattern-i. jpg$ 1440 50% 2880 ignore-reload Refresh_pattern-i. png$ 1440 50% 2880 ignore-reload Refresh_pattern-i. bmp$ 1440 50% 2880 ignore-reload
Refresh_pattern-i. doc$ 1440 50% 2880 ignore-reload Refresh_pattern-i. ppt$ 1440 50% 2880 ignore-reload Refresh_pattern-i. xls$ 1440 50% 2880 ignore-reload Refresh_pattern-i. pdf$ 1440 50% 2880 ignore-reload Refresh_pattern-i. rar$ 1440 50% 2880 ignore-reload Refresh_pattern-i. zip$ 1440 50% 2880 ignore-reload Refresh_pattern-i. txt$ 1440 50% 2880 ignore-reload
Quick_abort_min KB Quick_abort_max KB quick_abort_pct 95
Connect_timeout 1 minute Negative_ttl 0 Minutes Read_timeout seconds Pconn_timeout seconds Shutdown_lifetime 5 Seconds Strip_query_terms off
#snmp #snmp_port 3401 #acl snmppublic snmp_orgmunity snsimg #snmp_access Allow snmppublic localhost #snmp_access Deny All
Icp_port 0
# logfile Emulate_httpd_log on #logformat combined%{x-forwarded-for}>h%ui%un [%tl] "%rm%ru http/%rv"%Hs%<st "%{referer}>h" "%{user-agent}& Gt;h "%ss:%sh #access_log None #access_log/data/logs/access.log combined Logformat Squid%ts.%0 3tu%6tr%>a%ss/%03hs%<st%rm%ru%un%sh/%<a%mt Access_log/var/log/squid/access.log Squid #cache_store_log/var/log/squid/store.log Cache_store_log/dev/null Cache_log/var/log/squid/cache.log Logfile_rotate 12
# Miscellaneous Store_objects_per_bucket 15 client_db off |
4. Create a Directory
| The code is as follows |
|
/usr/sbin/groupadd Squid /usr/sbin/useradd-g Squid Squid Mkdir-p/var/log/squid Chown-r Squid:squid/var/log/squid Mkdir-p/var/{cache1,cache2} Chown-r Squid:squid/var/{cache1,cache2} Initializes the cache directory of Squid /usr/local/squid/sbin/squid-z Start squid /usr/local/squid/sbin/squid-d |
If you do not like this way of starting, you can find a squid start-up script, here do not release. When squid runs, you can use the following command to see the hit rate:
| The code is as follows |
|
| /usr/local/squid/bin/squidclient-p Mgr:info |
Well, the specific other squid use command you can only go to the search, it is here.