If you have jumped into this post directly then it is worth having a look at first three parts of this installation procedure from the following links
The final part of this four part installation procedure for Nagios installation covers the setup of webinterface for nagios, setup CGI authentication and user authentication using htpasswd for nagios website.
Create a new website on Apache
debian4r2# vi /etc/apache2/sites-available/Nagios
Add the following
ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin<Directory "/usr/local/nagios/sbin"> Options ExecCGI AllowOverride None Order allow,deny Allow from all AuthName "Nagios Access" AuthType Basic AuthUserFile /usr/local/nagios/etc/htpasswd.users Require valid-user </Directory>Alias /nagios /usr/local/nagios/share<Directory "/usr/local/nagios/share"> Options None AllowOverride None Order allow,deny Allow from all AuthName "Nagios Access" AuthType Basic AuthUserFile /usr/local/nagios/etc/htpasswd.users Require valid-user </Directory>
Enable the site on Apache
debian4r2:/etc/apache2/sites-available# a2ensite Nagios
Reload the config file for Apache to make the nagios site active
debian4r2:/etc/apache2/sites-available# /etc/init.d/apache2 reload
Reloading web server config…3638
Create and add the first Nagios user for the web interface
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
NOTE: The "-c" in the above command creates the htpasswd.users file and add nagiosadmin as a user.
Any new user should be added with the above command without the "-c"
Add more users
htpasswd /usr/local/nagios/etc/htpasswd.users nagios
Set the CGI Authentication in the Nagios CGI.cfg file
debian4r2# vi /usr/local/nagios/etc/cgi.cfg
Set the following value
Thats done and we are ready to go.
Access your Nagios website
Enter the username and password and off you go. From here on, you need to add contacts, contact groups, hosts,hostgroups,services…to get going with monitoring your network, hosts, services.