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会提示没有认证。
很惭愧,只做了一点微小的工作