This page describes how to use another server, one or more, to mirror the media for one or more sites running in one production server.
This is ideal when the production server (Stray
) is overloaded or you need to split the bandwidth usage among several servers.
Pittsburgh Indymedia was using this and because the bandwidth problems on Stray
we need to mirror the Media of sites hosted there.
All credits goes to MattToups
Table of content :
- Main server running sf-active
- Second server running squid
- New DNS records
You need one server with squid installed and running.
This is the squid.conf from the mirror running squid only.
Squid is running in port 80.
http_port 184.108.40.206:80 vhost defaultsite=argentina.indymedia.org
cache_peer 220.127.116.11 parent 80 0 no-query
acl all src 0.0.0.0/0.0.0.0
http_access allow all
### stuff below can be tweaked depending on the server used
cache_dir ufs /usr/local/squid/cache 20000 16 256
cache_mem 1024 MB
maximum_object_size 512 MB
### stuff below is for anonymizing
logformat common %>a %ui %un [%tl] "%rm %ru HTTP/%rv" %Hs %<st %Ss:%Sh
logformat common-noip 0.0.0.0 %ui %un [%tl] "%rm %ru HTTP/%rv" %Hs %<st %Ss:%Sh
access_log /usr/local/squid/logs/access.argentina.log common-noip
Apache main virtualhost
You need to add one or more lines in the main site virtualhost for the files you want to redirect to media.argentina.indymedia.org for this files be serverd by the squid mirror.
In the lines below we are serving all the files from
Those are the biggest files from the site, leaving the main production server to only server the php files.
RedirectMatch /im/(.*)$ http://media.argentina.indymedia.org/im/$1
RedirectMatch /images/(.*)$ http://media.argentina.indymedia.org/images/$1
RedirectMatch /uploads/(.*)$ http://media.argentina.indymedia.org/uploads/$1
Apache new virtualhost
You need to create a new virtualhost in the main production server to attend the requests of the squid mirror.
This is the new virtualhost we use for Indymedia Argentina.
SetEnv SITE_NAME argentina
CustomLog /usr/local/apache2/logs/argentina.indymedia.org-access.log indy
Options Multiviews FollowSymlinks
Allow from all
Redirect ^/$ http://argentina.indymedia.org
Apache Expires Module
You will probably like to use the Apache Module mod_expires which can be used to set a maximum age on your content. Say you change an image for a feature, the cache should change that in X time. Note that if you use a modification date based setting, the Expires header will not be added to content that does not come from a file on disk.
ExpiresDefault "access plus 3 hours"
You may want to override the default with different values per mediatype: Example configuration:
# enable expirations
# expire GIF images after a 12 hours in the client's cache
ExpiresByType image/gif A43200
# expire JPEG images 3 hours after the latest modification
ExpiresByType image/jpeg M10800
New DNS Record
You need to create the dns record for media.*.indymedia.org.
Change * with your domain or subdomain where the main site is running.
If everything goes fine now you have all the media served from the squid mirror.
- 15 Jul 2007
- 27 Aug 2007 added info about expiration done by apache