1. Generate Password using HTPASSWD
Use Apache to generate/usr/local/apache2/bin/htpasswd-c./htpasswd.users nagiosadmin
Copy to Nginx server, CP htpasswd.users/usr/local/nagios/etc/
2,/usr/local/nagios/etc/cgi.cfg in the configuration
authorized_for_system_information=nagiosadminauthorized_for_configuration_information= Nagiosadminauthorized_for_system_commands=nagiosadminauthorized_for_all_services= Nagiosadminauthorized_for_all_hosts=nagiosadminauthorized_for_all_service_commands= Nagiosadminauthorized_for_all_host_commands=nagiosadmin
3. Add the following lines in the nginx.conf configuration
Location/ { "Nagios Access"; Auth_basic_user_file /usr/local/nagios/etc/htpasswd.users; } ~ .*\. (pl|cgi)? $ { "Nagios Access"; Auth_basic_user_file /usr/local/nagios/etc/htpasswd.users; Fastcgi_param auth_user $remote _user; Fastcgi_param remote_user $remote _user; }
Pay special attention to the following two parameters, be sure to add:
Fastcgi_param auth_user $remote _user;
Fastcgi_param Remote_user $remote _user;
Otherwise entering Nagios will prompt for no authentication.
Nginx+nagios using User name password authentication settings