nginx+nagios使用用户名密码鉴权设置

1、使用htpasswd生成密码

使用apache生成/usr/local/apache2/bin/htpasswd -c ./htpasswd.users nagiosadmin      

拷贝到nginx的服务器上,cp htpasswd.users /usr/local/nagios/etc/

2、/usr/local/nagios/etc/cgi.cfg中的配置

authorized_for_system_information=nagiosadmin
authorized_for_configuration_information=nagiosadmin
authorized_for_system_commands=nagiosadmin
authorized_for_all_services=nagiosadmin
authorized_for_all_hosts=nagiosadmin
authorized_for_all_service_commands=nagiosadmin
authorized_for_all_host_commands=nagiosadmin

3、在nginx.conf中配置加入如下几行

location / {

        auth_basic "Nagios Access";
        auth_basic_user_file  /usr/local/nagios/etc/htpasswd.users;
    }
    location ~ .*\.(pl|cgi)?$
    {
      
      auth_basic "Nagios Access";
      auth_basic_user_file  /usr/local/nagios/etc/htpasswd.users;
     
      fastcgi_param AUTH_USER $remote_user;
      fastcgi_param REMOTE_USER $remote_user;

     }

特别注意下面两个参数,一定要加上:

            fastcgi_param AUTH_USER $remote_user;
            fastcgi_param REMOTE_USER $remote_user;

否则进入nagios会提示没有认证。

 

posted @ 2016-05-17 14:42  巫谢  阅读(1100)  评论(0编辑  收藏  举报