I am having trouble configuring Nagios on Arch Linux served by Nginx. The Nagios services run without hitches, but the serving via Nginx is broken. As you can see from the screenshot, the fonts are all messed up and the icons do not appear in the browser. I suspect that the paths to the CSS and image files are somehow broken and therefore not seved by Nginx.

Nagios screenshot

Here is my Nginx virtual server conf. I assume that I have made some stupid error, but I cannot spot the problem.

The error log shows the following:

*334 open() "/usr/share/nagios/share/nagios/images/ndisabled.gif" failed (2: No such file or directory)

However, the GIF is located at /usr/share/nagios/share/images/ndisabled.gif indicating that there is some confusion with the paths, which however I do not know how to best fix.

Probably one or the other Nginx/Nagios expert roaming this forum will find the issue in a microsecond!

server {
    server_name     nagios.bellaria www.nagios.bellaria;
    root            /usr/share/nagios/share;
    listen          80;
    index           index.php index.html index.htm;
    access_log      nagios.access.log;
    error_log       nagios.error.log;

    auth_basic            "Nagios Access";
    auth_basic_user_file  /etc/nagios/htpasswd.users;

    location ~ \.php$ {
        try_files       $uri = 404;
        fastcgi_index   index.php;
        fastcgi_pass    unix:/run/php-fpm/php-fpm.sock;
        include         fastcgi.conf;
    }

    location ~ \.cgi$ {
        root            /usr/share/nagios/sbin;
        rewrite         ^/nagios/cgi-bin/(.*)\.cgi /$1.cgi break;
        fastcgi_param   AUTH_USER $remote_user;
        fastcgi_param   REMOTE_USER $remote_user;
        fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
        include         fastcgi.conf;
        fastcgi_pass    unix:/run/fcgiwrap.sock;
    }

    location /stylesheets {
        alias /usr/share/nagios/share/stylesheets;
    }
}
  • it seems that the problem arises only with the CGI files. PHP files are displayed correctly. – aag Dec 20 '14 at 22:10
up vote 3 down vote accepted

Maybe nagios look for images on /nagios/images because of some configuration. Check the source code of page (Ctrl+ u ) to confirm.

You can do an alias for nagios:

location /nagios {
        alias /usr/share/nagios/share;
    }

Also check the config file cgi.cfg.

(Sorry for my english)


In freebsd on my nagios with nginx I use this config for php/CGI, maybe this help you with your cgi problem:

    location ~ ^/nagios/.+\.php$ {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_param SCRIPT_FILENAME    $document_root$fastcgi_script_name;
        fastcgi_param QUERY_STRING       $query_string;
        include fastcgi_params;
    }

    location ~ ^/nagios/.+\.cgi$ {
        fastcgi_pass unix:/var/run/fcgiwrap/nagios.socket;
#        fastcgi_pass 127.0.0.1:9000;
        fastcgi_param AUTH_USER "nagiosadmin";
        fastcgi_param REMOTE_USER "nagiosadmin";
        fastcgi_param SCRIPT_FILENAME    $document_root$fastcgi_script_name;

        include fastcgi_params;
    }
  • Skamasie, you de man! I added your location, and the problem is resolved! – aag Dec 20 '14 at 22:21
  • Still, I'd like to learn why it worked. Can you give me mroe explanations? I'd like to understand why I need an aliased location, when none of this was mentioned in the tutorials... – aag Dec 20 '14 at 22:22
  • I dont Known, in my setup I dont use that location, I think nagios aplication have defined to look images in /nagios/images for some reason.. can you check if you have orther images dir in /usr/share/nagios ? maybe that is the correct root path and not /usr/share/nagios/share – Skamasle Dec 20 '14 at 22:25

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.