Page 1 of 1

Nginx settings

Posted: Tue Jan 23, 2018 1:46 am
by matisse
Hi, i need your help.
I am trying to settings Nginx. But web-interface is no available via URL i need. I have domain, for example nagios.mydomain.ru.
Got error:

Code: Select all

[error] 6783#0: *51946 directory index of "/usr/local/nagios/share/nagios/" is forbidden
But i can get nagios via only servername.mydomain.ru.
It is my Nginx config:

Code: Select all

server {
        listen   80;
        server_name   nagios.mydomain.ru;
        access_log  /var/log/nginx/nagios-access.log;
        error_log   /var/log/nginx/nagios-error.log info;

        root /usr/local/nagios/share;
        index index.php;

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

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

        location ~ .cgi$ {
                root /usr/local/nagios/sbin/;
                include fastcgi_params;
                rewrite ^/nagios/cgi-bin/(.*).cgi /$1.cgi break;
                fastcgi_param AUTH_USER $remote_user;
                fastcgi_param REMOTE_USER $remote_user;
                fastcgi_pass unix:/var/run/fcgiwrap.socket;
                fastcgi_param SCRIPT_FILENAME /usr/local/nagios/sbin/$fastcgi_script_name;
                fastcgi_param PATH_INFO $fastcgi_script_name;
                }

        location ~ .php$ {
                include fastcgi_params;
                fastcgi_pass unix:/var/run/php-fpm/nagios.socket;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME /usr/local/nagios/share$fastcgi_script_name;
                fastcgi_param PATH_INFO $fastcgi_script_name;
                }

         location ~ (.*.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf))$ {
                root /usr/local/nagios/share/;
                rewrite ^/nagios/(.*) /$1 break;
                access_log off;  expires max;
        }

}
What the problem?
Thanks!

Re: Nginx settings

Posted: Tue Jan 23, 2018 2:30 pm
by mcapra
Did you use any sort of tutorial/documentation to set this up?

What operating system is Nagios Core installed on?

Can you share the contents of the error log? (/var/log/nginx/nagios-error.log)



This implies the nginx user doesn't have proper permissions over the /usr/local/nagios/share/nagios/ path:

Code: Select all

[error] 6783#0: *51946 directory index of "/usr/local/nagios/share/nagios/" is forbidden
Can we also see an output of the following command executed from the CLI of your Nagios Core machine:

Code: Select all

ls -al /usr/local/nagios/share

Re: Nginx settings

Posted: Tue Jan 23, 2018 4:36 pm
by dwhitfield
mcapra wrote:Did you use any sort of tutorial/documentation to set this up?
This would be really useful since we usually use apache. We can certainly lab something up, but setting it up like you did would be best.