1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
= mod_digest =
This is an Apache2 filter module that calculates the SHA1 digest of the
content served and stores it in a note, which can then be logged.
mod_digest is (c) Canonical, Ltd 2007, and published under the Apache
License.
Portions (C) Ben Laurie 2008.
== Installation ==
Under Ubuntu, the following should serve to install mod_digest. It assumes
you are using the threaded Apache structure:
sudo apt-get install libssl-dev apache2-threaded-dev
sudo apxs2 -i -c mod_digest.c
== Configuration ==
You will need to turn on filtering for the virtual server you wish to have
this information available from:
* Edit /etc/apache2/sites-available/<server>
* Insert a line like this in the relevant <Directory> stanza:
SetOutputFilter digest
* Optionally set a digest type:
DigestType md5
The default is SHA-1 (specified with "sha1"). Use the command:
openssl help
to see a list (under "Message Digest commands").
* Add a custom log which includes the range and the digest:
CustomLog /var/log/apache2/sha1.log "%>s \"%{Content-Range}o\" %{DIGEST}n \"%U\""
You should then see lines like this in the log file:
304 "-" - "/index.html"
200 "-" 0192ba11326fe2298c8cb4de616f4d4140213838 "/index.html"
206 "bytes 98914-102407/102408" 7c957b8b0a21f8e0440b143343808f3ceb661853 "/capabilities.pdf"
You need to log the Content-Range because otherwise you will be confused by
digests of partial files.
Enjoy!
Mark Shuttleworth and Ben Laurie
|