As the various bits of official Munin documentation seems to be in a limbo state where the current stable version (2.0.x) isn’t very well handled between the old and the new site, finding a good howto on setting up Munin with FastCGI and Nginx wasn’t as easy as it should have been.

There are articles (notably https://www.webfoobar.com/node/48 ) that are a bit on the overly complicated side, as it turns out, there exists a package called munin-nginx which simplifies things a lot.

So, assuming you are going to run munin without a URL prefix (https://munin.yoursite.com/) setting up Munin to use CGI for graphs and HTML turns out to be quite easy. The below steps were successfully performed using CentOS Linux release 7.2.1511, with munin-2.0.25-11 and munin-nginx-2.0.25-11.

sudo yum -y install munin munin-nginx nginx 

sudo sed -i 's/\(.*\)_strategy.*/\1_strategy cgi/;s/#cgiurl_graph/cgiurl_graph/' /etc/munin/munin.conf

for svc in munin-fcgi-graph munin-fcgi-html ; do sudo service $svc stop ; sudo chkconfig $svc on ; sudo service $svc start

htpasswd -c /etc/nginx/.htpasswd-munin-users munin

The Nginx config you need is:

<pre>server {
  listen 80; # IPv4
  listen [::]:80 ipv6only=on; # IPv6
  server_name munin.yoursite.com;
  
  ## Logs
  log_not_found off;
  error_log /var/log/nginx/munin.yoursite.com_error_log error;
  access_log off;

  location / {
    fastcgi_split_path_info ^(/)(.*);
    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_param SCRIPT_FILENAME /var/www/cgi-bin/munin-cgi-html;
    include fastcgi_params;
    fastcgi_pass unix:/var/run/munin/fcgi-munin-html.sock;
    auth_basic "Restricted";
    auth_basic_user_file /etc/nginx/.htpasswd-munin-users;

    # Serve static files
    location /static/ {
      alias /etc/munin/static/;
      expires 30d;
    }

    # Munin CGI graph
    location ^~ /munin-cgi/munin-cgi-graph/ {
      access_log off;
      fastcgi_split_path_info ^(/munin-cgi/munin-cgi-graph)(.*);
      fastcgi_param PATH_INFO $fastcgi_path_info;
      fastcgi_param SCRIPT_FILENAME /var/www/cgi-bin/munin-cgi-graph;
      include fastcgi_params;
      fastcgi_pass unix:/var/run/munin/fcgi-munin-graph.sock;

      # Bypass cache.
      fastcgi_cache_bypass 0;
      fastcgi_no_cache 0;
      expires epoch;
    }
  }
}

Then restart nginx, and you should be able to use munin with cgi-generated graphs and html pages:

sudo service nginx restart