# Apache configuration example for Squid-behind-Apache setup # Include the following in the Apache config like so: # # Include ${buildout:directory}/etc/httpd-vhost.conf # # Or copy/paste into the relevant VirtualHost block # or into the default host if not using VirtualHosts. # The main domain ServerName ${apache-vhost:hostname} RewriteEngine On # Split-view caching: Add "X-Anonymous" to request # to segregate authenticated/anonymous responses SetEnvIf Authorization .+ is_authenticated SetEnvIf Cookie "(^|.*; )__ac=" is_authenticated RequestHeader set X-Anonymous True env=!is_authenticated # Split-view caching: Rewrite s-maxage in response # to exclude from intermediary caching proxies Header edit Cache-Control "^(.*)s-maxage=[0-9]+(.*)$" "$1s-maxage=0$2" # Normalize Accept-Encoding header to optimize variant caching # 1) if gzip is allowed, rewrite Accept-Encoding to just "gzip" # 2) if gzip is not allowed, unset Accept-Encoding header # 3) also unset Accept-Encoding for images and other common binaries SetEnvIfNoCase Request_URI "\.(jpe?g|png|gif|swf|pdf|gz|tgz|bz2|tbz|zip)$" unset_accept_encoding SetEnvIf Request_URI "/image_[^/]*$" unset_accept_encoding SetEnvIf Accept-Encoding ".*gzip.*" set_accept_encoding !env=unset_accept_encoding RequestHeader unset Accept-Encoding RequestHeader set Accept-Encoding gzip env=set_accept_encoding # Remove trailing slash to avoid duplicates in caching proxy, # 1) for search engines, redirect to normalized version # 2) for everyone else, just strip the trailing slash RewriteCond %{HTTP_USER_AGENT} ^Yahoo.* [NC,OR] RewriteCond %{HTTP_USER_AGENT} ^Googlebot.* [NC,OR] RewriteCond %{HTTP_USER_AGENT} ^msnbot.* [NC] RewriteRule ^/(.*)/$ /$1 [R=301] RewriteRule ^/(.*)/$ /$1 # And finally, pass the request to the backend RewriteRule ^/(.*)$ http://${apache-vhost:backend}/VirtualHostBase/http/${apache-vhost:hostname}:80/${apache-vhost:zope-path}/VirtualHostRoot/$1 [P] # Additional domains: # Avoid the use of the ServerAlias directive in the main domain VirtualHost # container as this tends to undermine the ability of external search engines # to accurately assess page uniqueness. Instead perform a 301 redirect like so. ServerName www.${apache-vhost:hostname} ServerAlias *.${apache-vhost:hostname} RedirectPermanent / http://${apache-vhost:hostname}/ # References # http://plone.org/documentation/kb/plone-apache/vhm # http://httpd.apache.org/docs/2.2/rewrite # http://httpd.apache.org/docs/2.2/mod/mod_setenvif.html # http://httpd.apache.org/docs/2.2/mod/mod_headers.html