Munin Virtual Host Configuration on Ubuntu 14.04 and Apache 2.4

Submitted on Jul 09, 2014, 1:26 p.m.

Having switched to Nginx a while ago, I was recently asked to use Apache for a client installation. There have been some significant changes in 2.4 from 2.2, include the 'Requires' option.  I also wanted to create a virtualhost entry for Munin on this machine. It took a little while to figure this out, in particular on Apache 2.4. I'm also using the built-in cron task to generate graphs. Here's the complete Virtualhost configuration for Munin on Ubuntu 14.04 and Apache 2.4

1<VirtualHost *:80>
2 ServerName munin.yourhost.com
3 ServerAlias munin
4 ServerAdmin yours@email.com
5 DocumentRoot "/var/cache/munin/www"
6 DirectoryIndex index.html
7
8 <Directory "/var/cache/munin/www">
9 AuthUserFile /etc/apache/htpasswords
10 AuthName "admin"
11 AuthType Basic
12 require valid-user
13 </Directory>
14
15
16 ErrorLog /var/log/apache2/munin.yourhost.com-error.log
17 CustomLog /var/log/apache2/munin.yourhost.com-access.log combined
18
19 # Rewrites
20 RewriteEngine On
21
22 # Static content in /static
23 RewriteRule ^/favicon.ico /etc/munin/static/favicon.ico [L]
24 RewriteRule ^/static/(.*) /etc/munin/static/$1 [L]
25
26 # HTML - Uncomment for CGI graphs
27 #RewriteCond %{REQUEST_URI} .html$ [or]
28 #RewriteCond %{REQUEST_URI} =/
29 #RewriteRule ^/(.*) /usr/lib/munin/cgi/munin-cgi-html/$1 [L]
30
31 # Images
32 #RewriteRule ^/(.*) /usr/lib/munin/cgi/munin-cgi-graph/$1 [L]
33
34 <Directory "/etc/munin/static">
35 Require all granted
36 </Directory>
37
38 # Ensure we can run (fast)cgi scripts
39 <Directory "/usr/lib/munin/cgi">
40 Options +ExecCGI
41 Require all granted
42 <IfModule mod_fcgid.c>
43 SetHandler fcgid-script
44 </IfModule>
45 <IfModule !mod_fcgid.c>
46 SetHandler cgi-script
47 </IfModule>
48 </Directory>
49</VirtualHost>