===== How to Install Nagios Monitoring Tool on Debian 12 =====
\\
==== Installation from Debian repository ====
$ sudo apt install nagios4 nagios4-common monitoring-plugins-contrib nagios-nrpe-plugin
$ sudo systemctl enable nagios4
$ sudo systemctl is-enabled nagios4
$ sudo systemctl status nagios4
$ sudo systemctl is-enabled apache2
$ sudo systemctl status apache2
Connect to nagios at http://nagios_host_ip_address/nagios4/
==== Enable Nagios Authentication ====
In file /etc/nagios4/cgi.conf change value of use_authentication to 1.
Restart nagios4 service. From now on, only user 'nagiosadmin' will be allowed to access your. You can still access the Nagios dashboard, but the reporting and monitoring page will be denied.
==== Setting up Apache Basic Auth for Nagios ====
To enable the required modules, cgi, cgid, and rewrite, run command
sudo a2enmod cgi cgid rewrite
Open /etc/apache2/conf-available/nagios4-cgi.conf, find the section of and replace the default configuration with the following. With this you will enable the Apache basic_auth module Nagios web contents.
Options FollowSymLinks
DirectoryIndex index.php index.html
AllowOverride AuthConfig
Options None
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Core"
AuthType Basic
AuthUserFile /etc/nagios4/htdigest.users
Require valid-user
Require all denied
To create a new user nagiosadmin for Apache basic auth
sudo htpasswd /etc/nagios4/htdigest.users nagiosadmin
Input your password two times. Restart the apache2 service.