Nginx + Nagios + PNP4Nagios Working Conf File

  • Thu 12 May 2011

  • This is a working config I had for Nginx, Nagios and PNP4Nagios.

    Hopefully this helps someone. I definitely had to hunt and piece together "recommendations" to make this work.

    I also had WordPress in the root of the site.

    Nagios was domain.tld/nagios and PNP4Nagios was domain.tld/nagios/pnp4nagios

    server {
    server\_name "Server.Name";
    access\_log /var/log/nginx/$host.access.log;
    error\_log /var/log/nginx/$host.error.log;
    root /var/www;
    index index.php index.html;
    location / {
    try\_files $uri $uri/ /index.php;
    }
    location /nagios {
    alias /opt/nagios/share/;
    auth\_basic "Restricted";
    auth\_basic\_user\_file /opt/nagios/etc/htpasswd.users;
    }
    location ~ ^/nagios/(.\*\\.php)$ {
    alias /opt/nagios/share/$1;
    include /etc/nginx/fastcgi.conf;
    fastcgi\_pass unix:/var/run/php5-fpm.sock;
    }
    location ~ \\.cgi$ {
    root /opt/nagios/sbin/;
    rewrite ^/nagios/cgi-bin/(.\*)\\.cgi /$1.cgi break;
    fastcgi\_param AUTH\_USER $remote\_user;
    fastcgi\_param REMOTE\_USER $remote\_user;
    include /etc/nginx/fastcgi.conf;
    fastcgi\_pass unix:/var/run/fcgiwrap.sock;
    }
    location /pnp4nagios {
    alias /opt/pnp/share;
    }
    location ~ ^(/pnp4nagios.\*\\.php)(.\*)$ {
    root /opt/pnp/share;
    include /etc/nginx/fastcgi.conf;
    rewrite ^/pnp4nagios/(.\*)$ /$1; break;
    fastcgi\_split\_path\_info ^(.+\\.php)(.\*)$;
    fastcgi\_param PATH\_INFO $fastcgi\_path\_info;
    fastcgi\_pass unix:/var/run/php5-fpm.sock;
    }
    location ~ \\.php$ {
    include /etc/nginx/fastcgi.conf;
    fastcgi\_pass unix:/var/run/php5-fpm.sock;
    try\_files $uri =404;
    }
    }
    

    Comments !

    social