Using Squid to accelerate httpd

From TekPedia

Jump to: navigation, search

Use squid in httpd accelerator mode. even for the most basic dynamic website with a couple of images and a stylesheet this will reduce the load on apache by at least 90% (meaning fewer apache processes are needed)

in httpd.conf:

BindAddress 127.0.0.1
Listen 81
Port 81

in squid.conf for squid 2.5 (applies to debian default -- change example.com as appropriate -- order does matter for acl directives)

http_port 80
cache_replacement_policy heap GDSF
emulate_httpd_log on
acl Safe_ports 81
acl okdomains dstdomain example.com www.example.com
http_access deny !okdomains
#http_access deny all (comment out!)
http_access allow all
visible_hostname example.com
httpd_accel_host virtual
httpd_accel_port 81
http_accel_single_host off
httpd_accel_uses_host_header on

for squid 2.6, the config file syntax is a bit different; you will want something like

http_port 80 vhost
cache_replacement_policy heap GDSF
emulate_httpd_log on
acl Safe_ports 81
acl okdomains dstdomain example.com www.example.com
http_access deny !okdomains
#http_access deny all (comment out!)
http_access allow all
visible_hostname example.com
cache_peer 127.0.0.1 parent 81 0 no-query originserver

You can download my complete version 2.5 squid.conf file here: http://www.corpuselectronica.com/blog/aws/2005-06-27-httpd_acceleration_with_squid.

Personal tools