(notes copied from a mail, which might be suitable starting point)
In the (default) access log, Apache logs the HTTP status code directly
after the URL. So you see
"GET /url/... HTTP/1.1" 200 ...
for a request that was answered with a "200 OK" reply.
For a redirect however, you would see a reply with
"GET /url/... HTTP/1.1" 302 ...
where the number is from "302 Found", a reply that comes with a Location
header containing the URL to be followed.
So to verify that MirrorBrain is redirecting correctly, you could look
into the access_log in the first place. If the access_log contains only
"200" responses, no redirects happen.
For the record, let me mention an additional way to check for redirects.
You can look at the protocol level with "curl -sI <URL>", which will
make the server responses visible (only the header lines due to the -I).
Example screenshot (of a working redirect):
http://mirrorbrain.org/static/images/screenshots/redirect.jpg
With a browser like Firefox, it is harder to notice if a redirect
happens.
With some Apache configuration, MirrorBrain allows logging several more
details out of the box, that complement the normal access log:
- which mirror a client was sent to
- data about client origin: country, continent, autonomous system number
and network prefix.
- the reason why a particular mirror was selected
- size of the file in question
- files for which no mirror was found
- (with Apache's native logging means) things like the number of bytes
actually transferred, byterange headers requested by the client or
other headers
All these could be logged conditionally, using Apache's SetEnvIf
directive combined with "CustomLog env=....".
Here's an example for defining a new LogFormat which logs all of the
above. The format is identical to the "access log" format, but with
additional data added at the end of the log lines:
# In order to log the mirror we redirected to, we use the
# %{X-MirrorBrain-Chose-Mirror}o logging variable to log that headers
# content
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" \
%{X-MirrorBrain-Mirror}o r:%{MB_REALM}e \
%{MB_CONTINENT_CODE}e:%{MB_COUNTRY_CODE}e ASN:%{ASN}e P:%{PFX}e \
size:%{MB_FILESIZE}e %{Range}i" combined_redirect
To use the newly defined log format, you use "combined_redirect" with
the CustomLog directive of the virtual host in question, instead of the
usually defined "combined" log format.
|