Tips / Nginx

Nginx configuration for Munin


Munin is a network/systems monitoring service, together with Nagios it is one of the most demanding apps by system/network administrators. It outputs all the server monitoring data  in graphs through a web interface. It’s installation is simple, fast and works perfectly.

This tutorial will help you to set up the Munin on a running Nginx server, and also we will cover the installation of Nginx Munin’s plugins to monitor nginx requests and nginx status.

After installing Munin (let’s assume it was done at /var/www/html/munin), you should create a server.conf file or you can add it directly into nginx.conf file, as you like. It should contain this code:

server {
    listen 80 default_server;
    access_log logs/server-access_log;
    server_name _; # This is just an invalid value which will never trigger on a real hostname.

     server_name_in_redirect off;
     root  /var/www/html;

# access munin
location /munin {
        auth_basic "Administrator Login";
        auth_basic_user_file /var/www/.htpasswd;

        location /nginx_status {
        stub_status on;
        access_log   off;
        deny all;


After that restart nginx service:

service nginx restart

Then, you can browse Munin stats using: http://server.ip/munin/, it will ask you for an username and password, which we will define now:

Create a new user for munin directory and set it’s password:

htpasswd -c /var/www/.htpasswd muninuser1

All done, now everytime you browse the munin directory, it will ask you for that username and password.

One of the main advanges of Munin is the fact that it can monitor almost any service from a Linux/Unix System, and if you are using Nginx, let’s also monitor nginx requests and status.

Add this code to /etc/munin/plugin-conf.d/munin-node:

env.url http://localhost/nginx_status

Now let’s configure the munin plugins:

ln -s /usr/share/munin/plugins/nginx_request /etc/munin/plugins/ -v
ln -s /usr/share/munin/plugins/nginx_status /etc/munin/plugins/ -v

Restart munin:

service munin-node restart

That’s all.

See also:  Official Munin Website | MuninExchange


Popular search terms:

  • munin through http
  • centos munin nginx
  • conf d munin nginx
  • configuring munin stats

Esteban Borges

Linux Geek, Webperf Addict, Nginx Fan. CTO @Infranetworking

  • A little error, Restart munin:
    service nginx restart
    in place of
    service munin-node restart

  • admin

    Thanks, it has been corrected.

  • Pavel Nikolov

    Thanks this helped me!