# Nagios served by NginX

**URL:** <https://www.ruby-forum.com/t/nagios-served-by-nginx/201114>\
**Category:** NGINX\
**Created:** [December 30, 2010, 5:25pm UTC](https://www.ruby-forum.com/t/nagios-served-by-nginx/201114 "2010-12-30T17:25:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [December 30, 2010, 5:25pm UTC](https://www.ruby-forum.com/t/nagios-served-by-nginx/201114/1 "2010-12-30T17:25:07Z")

</div>

Can some one please help me setting up Nagios on NginX. I installed  
spawn-fcgi and fcgiwrap in Ubuntu, and I have Nagios 3.2.3 installed in  
/opt/nagios. So I have the two folders: /opt/nagios/share for web files,  
and /opt/nagios/sbin for cgi scripts.

I tried with this config (with no success though):

```auto
location / {
    root /opt/nagios/share;
    index index.html;

    rewrite ^/nagios/images/(.*)\.png /images/$1.png break;

    auth_basic "Restricted";
    auth_basic_user_file conf/htpasswd;
  }

  location ~ \.cgi$ {
    root /opt/nagios/sbin;
    rewrite ^/nagios/cgi-bin/(.*)\.cgi /$1.cgi break;

    include /etc/nginx/fastcgi_params;

          fastcgi_pass unix:/var/run/fcgiwrap.socket;
          fastcgi_param SCRIPT_FILENAME
/opt/nagios$fastcgi_script_name; # same path as above

    auth_basic "Restricted";
    auth_basic_user_file conf/htpasswd;

    fastcgi_param AUTH_USER $remote_user;
    fastcgi_param REMOTE_USER $remote_user;
  }
```

This config is adaped from  
[http://www.matejunkie.com/howto-let-nginx-serve-the-nagios-web-interface/](http://www.matejunkie.com/howto-let-nginx-serve-the-nagios-web-interface/)

Does anyone use Nagios with NginX and can send me a working  
configuration?

Thank you in advance,  
Vlad.

Posted at Nginx Forum:

> **[Nagios served by NginX](https://forum.nginx.org/read.php?2,162278,162278#msg-162278)**
>
> Can some one please help me setting up Nagios on NginX. I installed spawn-fcgi and fcgiwrap in Ubuntu, and I have Nagios 3.2.3 installed in /opt/nagios. So I have the two folders: /opt/nagios/share for web files, and /opt/nagios/sbin for cgi scripts....

---

<div class="post-metadata">

**Author:** ![nofun](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/839c29/32.png) [@nofun](https://www.ruby-forum.com/u/nofun)\
**Post date:** [December 30, 2010, 5:33pm UTC](https://www.ruby-forum.com/t/nagios-served-by-nginx/201114/2 "2010-12-30T17:33:17Z")

</div>

This works for me:

http  
{  
include /etc/nginx/mime.types;  
default\_type application/octet-stream;  
sendfile on;  
tcp\_nopush on;  
client\_max\_body\_size 6m;  
gzip on;  
gzip\_min\_length 0;  
gzip\_comp\_level 6;  
gzip\_types text/css application/json application/x-javascript  
text/xml  
application/xml application/xml+rss text/javascript;  
log\_format main '$remote\_addr - $remote\_user [$time\_local] $status  
’  
'“$request” $body\_bytes\_sent “$http\_referer” ’  
‘“$http\_user\_agent” “$http\_x\_forwarded\_for”’;  
access\_log /var/log/nginx/access.log main;  
access\_log off;  
root /var/www/html;  
server  
{  
listen 10.0.1.163;  
server\_name [dev.local.com](http://dev.local.com);  
location = /nagios  
{  
rewrite ^/nagios/ permanent;  
}  
location /nagios/  
{  
index index.php index.html;  
alias /usr/local/nagios/share/;  
}  
location /  
{  
index index.php index.html;  
error\_page 404 = @joomla;  
log\_not\_found off;  
}  
location @joomla  
{  
rewrite ^(._)$ /index.php?q=$1 last;  
}  
location ~ ^/nagios/(._.php)$  
{  
alias /usr/local/nagios/share/$1;  
fastcgi\_pass 127.0.0.1:9000;  
include fcgi;  
auth\_basic “Restricted”;  
auth\_basic\_user\_file htpasswd;  
}  
location ~ .cgi$  
{  
root /usr/local/nagios/sbin/;  
rewrite ^/nagios/cgi-bin/(.\*).cgi /$1.cgi break;  
fastcgi\_pass 127.0.0.1:49233;  
include fcgi;

```
            auth_basic "Restricted";
            auth_basic_user_file htpasswd;

            fastcgi_param AUTH_USER $remote_user;
            fastcgi_param REMOTE_USER $remote_user;
    }
    location ~ \.php$
    {
            include fcgi;
            fastcgi_pass 127.0.0.1:9000;
    }

}

```

---

<div class="post-metadata">

**Author:** ![nofun](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/839c29/32.png) [@nofun](https://www.ruby-forum.com/u/nofun)\
**Post date:** [December 30, 2010, 6:06pm UTC](https://www.ruby-forum.com/t/nagios-served-by-nginx/201114/3 "2010-12-30T18:06:32Z")

</div>

Thank you so much for the very fast reply. It does work perfectly.  
Thanks.

Posted at Nginx Forum:

> **[Re: Nagios served by NginX](https://forum.nginx.org/read.php?2,162278,162289#msg-162289)**
>
> Can some one please help me setting up Nagios on NginX. I installed spawn-fcgi and fcgiwrap in Ubuntu, and I have Nagios 3.2.3 installed in /opt/nagios. So I have the two folders: /opt/nagios/share for web files, and /opt/nagios/sbin for cgi scripts....
