.. _example-webserver-nginx-cron:

============================
 Nginx Static Configuration
============================

This example describes how to set up nginx for serving content generated by munin via cron.


Site Configuration
==================

Nginx is quite good at serving static files, and as such the configuration is
mostly in place already.

The paths are as in use on a Debian Linux system.

.. index::
   triple: munin-cron; nginx configuration; example

Add the following to ``/etc/nginx/sites-enabled/default``::

    location /munin/static/ {
        alias /etc/munin/static/;
        expires modified +1w;
    }

    location /munin/ {
        auth_basic            "Restricted";
        # Create the htpasswd file with the htpasswd tool.
        auth_basic_user_file  /etc/nginx/htpasswd;

        alias /var/cache/munin/www/;
        expires modified +310s;
    }

For Zoom to work you also need to add the following to the same configuration file::

    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_pass unix:/var/run/munin/fastcgi-graph.sock;
        include fastcgi_params;
    }

If this is a dedicated Munin server, you might want to redirect the frontpage as well::

    location = / {
        rewrite ^/$ munin/ redirect; break;
    }
