Nagios served by NginX

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):

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/

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

Thank you in advance,
Vlad.

Posted at Nginx Forum:

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;
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;
    }

}

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

Posted at Nginx Forum: