-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Draft: Install Nagios on Debian 12 & Ubuntu 22.04 #7325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
…and Health Checks
* [update] Securing Nginx With ModSecurity (#7167) Fixes: #6803 * [NEW] Getting Started with HAProxy Part 2: HTTP Load Balancing (#7095) * Getting Started with HAProxy Part 2: HTTP Load Balancing * Tech Edit 1 * Tech Edit 2 * Tech Edit 3 * Tech Edit 4 * Copy edits --------- Co-authored-by: Nathan Melehan <[email protected]> * [update] January Marketplace doc updates (#7178) * jan marketplace distro& instruction * rabbitmq lts add * review for January Marketplace release * review for January Marketplace release --------- Co-authored-by: Magda Sulik <[email protected]> * Update theme (#7179) - Update onetrust geolocation Co-authored-by: Nathan Melehan <[email protected]> --------- Co-authored-by: Rajakavitha Kodhandapani <[email protected]> Co-authored-by: Adam Overa <[email protected]> Co-authored-by: Nathan Melehan <[email protected]> Co-authored-by: hmorris3293 <[email protected]> Co-authored-by: Magda Sulik <[email protected]>
[Release] v1.361.0
[Release Candidate] v1.362.0
[Release Candidate] v1.363.0
[Release Candidate] v1.364.0
[Release] v1.365.0
[Release Candidate] v1.366.0
[Release Candidate] v1.367.0
[Release] v1.368.0
[Release] v1.369.0
[Release] v1.370.0
[Release] v1.371.0
[Release Candidate] v1.372.0
[Release] v1.373.0
[Release] v1.374.0
[Release Candidate] v1.375.0
[Release] v1.376.0
[Release Candidate] v1.377.0
[Release] v1.378.0
[Release Candidate] v1.379.0
[Release Candidate] v1.380.0
[Release Candidate] v1.381.0
[Release Candidate] v1.382.0
[Release Candidate] v1.383.0
[Release] v1.384.0
[Release Candidate] v1.385.0
[Release Candidate] v1.386.0
[Hotfix] v1.386.1
|
||
apt search nagios | ||
|
||
- Missing package: One of the listed packages may not be available in your distro's repositories. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Missing package: One of the listed packages may not be available in your distro's repositories. | |
This command helps you confirm whether the packages exist in your distro's repositories. |
|
||
- Missing package: One of the listed packages may not be available in your distro's repositories. | ||
|
||
Or any of these common issues: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or any of these common issues: | |
Common issues and how to resolve them: | |
- **Missing package**: One or more packages may not be available in your distro's repositories. Double-check your `/etc/apt/sources.list` and run `sudo apt update` to refresh the cache. |
|
||
Or any of these common issues: | ||
|
||
- Permission issues: If you're not using `sudo`, you might see permission denied. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Permission issues: If you're not using `sudo`, you might see permission denied. | |
- **Permission denied**: If you didn't use `sudo`, the install will fail. Always run `apt` commands with elevated privileges. |
Or any of these common issues: | ||
|
||
- Permission issues: If you're not using `sudo`, you might see permission denied. | ||
- Network: A broken internet connection or unreachable mirror can cause download failures. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Network: A broken internet connection or unreachable mirror can cause download failures. | |
- Network: A broken internet connection or unreachable mirror can prevent downloads. Try pinging a known host or switching mirrors. |
|
||
- Permission issues: If you're not using `sudo`, you might see permission denied. | ||
- Network: A broken internet connection or unreachable mirror can cause download failures. | ||
- Broken dependencies: If your system has conflicting packages or unmet dependencies, `apt` will usually suggest a fix. Then isolate the problem by installing packages one at a time: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Broken dependencies: If your system has conflicting packages or unmet dependencies, `apt` will usually suggest a fix. Then isolate the problem by installing packages one at a time: | |
- Broken dependencies: If your system has conflicting packages or unmet dependencies, `apt` usually suggests a fix. To isolate the problem, install packages one at a time: |
|
||
1. Create A Digest-authenticated user | ||
|
||
Using the `-c ` flag creates the file if it doesn't exist. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the `-c ` flag creates the file if it doesn't exist. | |
Using the `-c ` flag creates the file if it doesn't exist **and overwrites it** if it already contains users. To preserve existing entries, omit `-c`. |
|
||
1. Update Apache Configuration | ||
|
||
Open `/etc/nagios4/apache2/conf` in your preferred editor and make the following changes: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Open `/etc/nagios4/apache2/conf` in your preferred editor and make the following changes: | |
Open `/etc/nagios4/apache2/sites-available/000-default.conf` in your preferred editor with elevated privileges (e.g., `sudo nano`) and make the following changes: (Note: If `/etc/apache2/conf-available/nagios4.conf` doesn't exist it will show `[ New File ]` just above the commands line which means you're are creating it manually. Copy the config block example shown below and paste it in, then use `Ctrl + O` and exit with `Ctrl + X`.) | |
{{< note>}} For Debian 12/Ubuntu 22.04, Nagios web access is typically configured in `/etc/apache2/sites-available/000-default.conf`. Some older guides may reference `/etc/nagios4/apache2/conf`, which may not exist or be used in modern setups. | |
{{</ note>}} |
|
||
Open `/etc/nagios4/apache2/conf` in your preferred editor and make the following changes: | ||
|
||
Inside `<DirectoryMatch>` block: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inside `<DirectoryMatch>` block: | |
Example: Inside `<DirectoryMatch>` block: | |
Following the lines: | |
ServerAdmin webmaster@localhost | |
DocumentRoot /var/www/html | |
Copy or type in your content: | |
#Restrict access to Nagios CGI interface | |
<Directory "/usr/local/nagios/sbin/cmd.cgi"> | |
AuthType Digest | |
AuthName "Restricted Nagios Command Access" | |
AuthDigestProvider file | |
AuthUserFile /usr/local/nagios/etc/htdigest.users | |
Require user nagiosadmin | |
</Directory> |
This example restricts access to cmd.cgi
to a single user (nagiosadmin
). You can expand this to include a group (multiple users) or use Require valid-user
, depending on your authentication strategy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add instructions or link to TS section here for users who can't get Weblish to work when trying DirectoryMatchBlock.
|
||
1. Simplified Access Control for `cmd.cgi` | ||
|
||
This configuration enforces authentication and IP-based filtering for the Nagios command interface using a streamlined `<Files "cmd.cgi">` block. It's designed for clarity and ease of setup, especially for contributors who don't need group-based access or multi-realm authentication. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This configuration enforces authentication and IP-based filtering for the Nagios command interface using a streamlined `<Files "cmd.cgi">` block. It's designed for clarity and ease of setup, especially for contributors who don't need group-based access or multi-realm authentication. | |
The following `<Files "cmd.cgi">` block provides an example of a simplified, file-specific access control method designed for clarity with the Nagios command interface. It's ideal for contributors who prefer minimal setup or who are validating access to `cmd.cgi` directly. | |
If you've already configured a broader `<DirectoryMatch>` block (e.g., for /usr/lib/nagios4/cgi-bin/`), this example acts as a targeted override. It streamlines authentication and IP filtering for just the command interface, and may require commenting out overlapping `Require ip` lines to avoid conflicts--especially if you're shifting access control to the file level or relying on firewall rules. |
AuthDigestProvider file | ||
AuthUserFile "/etc/nagios4/htdigest.users" | ||
Require valid-user | ||
Allow from 127.0.0.1 <your-trusted-ip> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allow from 127.0.0.1 <your-trusted-ip> | |
Require from 127.0.0.1 <your-trusted-ip> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This reflects the Apache 2.4+ syntax, which is default in both Debian 12 and Ubuntu 22.04.
Allow from 127.0.0.1 <your-trusted-ip> | ||
</Files> | ||
|
||
{{< caution >}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{{< caution >}} |
|
||
{{< caution >}} | ||
|
||
Replace <your-trusted-ip> with your actual IP address. Avoid hardcoding contributor IPs in PRs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace <your-trusted-ip> with your actual IP address. Avoid hardcoding contributor IPs in PRs. |
|
||
Replace <your-trusted-ip> with your actual IP address. Avoid hardcoding contributor IPs in PRs. | ||
|
||
{{< /caution >}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{{< /caution >}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the caution, it is redundant.
|
||
{{< /caution >}} | ||
|
||
For advanced scenarios--such as managing access by user groups, supporting IPv6 ranges, or customizing multiple directory paths--refer to the full [Advanced Apache](#advanced-apache-configuration) configuration example below. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For advanced scenarios--such as managing access by user groups, supporting IPv6 ranges, or customizing multiple directory paths--refer to the full [Advanced Apache](#advanced-apache-configuration) configuration example below. | |
For advanced scenarios--such as managing access by user groups, supporting IPv6 ranges, or customizing multiple directory paths--see the full [Advanced Apache Configuration](#advanced-apache-configuration) section below. |
|
||
sudo a2enmod rewrite cgi auth_digest authz_groupfile | ||
|
||
1. Restart Apache: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1. Restart Apache: | |
Restart Apache: |
AuthGroupFile "/etc/group" | ||
AuthName "Nagios4" | ||
AuthType Digest | ||
Allow from 127.0.0.1 198.51.100.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allow from 127.0.0.1 198.51.100.0 | |
Require from 127.0.0.1 198.51.100.0 |
|
||
1. Update `<DirectoryMatch>` Block | ||
|
||
<DirectoryMatch (/usr/share/nagios4/htdocs|/usr/lib/cgi-bin/nagios4|/etc/nagios4/stylesheets)> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<DirectoryMatch (/usr/share/nagios4/htdocs|/usr/lib/cgi-bin/nagios4|/etc/nagios4/stylesheets)> | |
<DirectoryMatch "^(/usr/share/nagios4/htdocs|/usr/lib/cgi-bin/nagios4|/etc/nagios4/stylesheets)"> |
|
||
## Advanced Apache Configuration | ||
|
||
Use this version if you need group-based access, IPv6 support, and broader directory matching across multiple Nagios paths. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use this version if you need group-based access, IPv6 support, and broader directory matching across multiple Nagios paths. | |
Use this version if you are managing group-based multi-access, enforcing IPv6 restrictions, or customizing Nagios interface paths. For simpler setups, refer to the basic configuration [Configure Apache Authentication](#configure-apache-authentication) section above. |
|
||
sudo a2enmod authz_groupfile | ||
|
||
{{< note>}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{{< note>}} |
|
||
{{< note>}} | ||
|
||
Restart the Apache service to apply changes: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Restart the Apache service to apply changes: | |
1. Restart the Apache service to apply changes: |
|
||
sudo systemctl restart apache2 | ||
|
||
{{< /note >}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{{< /note >}} |
|
||
For advanced scenarios--such as managing access by user groups, supporting IPv6 ranges, or customizing multiple directory paths--refer to the full [Advanced Apache](#advanced-apache-configuration) configuration example below. | ||
|
||
1. Enable Apache Modules and Restart |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1. Enable Apache Modules and Restart | |
1. Validate and Enable Apache Modules then Restart |
For advanced scenarios--such as managing access by user groups, supporting IPv6 ranges, or customizing multiple directory paths--refer to the full [Advanced Apache](#advanced-apache-configuration) configuration example below. | ||
|
||
1. Enable Apache Modules and Restart | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validate Apache configuration
sudo apachect1 configstest
|
||
1. Enable Apache Modules and Restart | ||
|
||
Enable require modules: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enable require modules: | |
Enable required modules: |
|
||
Enable require modules: | ||
|
||
sudo a2enmod rewrite cgi auth_digest authz_groupfile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sudo a2enmod rewrite cgi auth_digest authz_groupfile | |
sudo a2enmod rewrite | |
sudo a2enmod cgi | |
sudo a2enmod auth_digest | |
sudo a2enmod authz_groupfile |
|
||
sudo a2enmod rewrite cgi auth_digest authz_groupfile | ||
|
||
1. Restart Apache: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1. Restart Apache: | |
1. Restart Apache to apply changes: |
1. Restart Apache: | ||
|
||
sudo systemctl restart apache2 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If `configtest` returns anything other than `Syntax OK`, double-check your `<DirectoryMatch>` and `Require` directives for typos or misplaced quotes. |
## Monitor Hosts and Services | ||
|
||
- Use the left sidebar in Nagios to view Hosts and Services. | ||
- Add new hosts by editing files in `/etc/nagios4/conf.d/`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Add new hosts by editing files in `/etc/nagios4/conf.d/`. | |
- Add new hosts by editing configuration files in: | |
`/etc/nagios4/conf.d/` | |
- After making changes, validate your configuration before restarting: | |
sudo nagios4 -v /etc/nagios4/nagios.cfg | |
If errors appear, Nagios will point to the specific file and line number. Fix those *before* restarting. | |
|
||
- Use the left sidebar in Nagios to view Hosts and Services. | ||
- Add new hosts by editing files in `/etc/nagios4/conf.d/`. | ||
- Restart Nagios after changes: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Restart Nagios after changes: | |
- Restart Nagios after changes: |
authors: ["D Hoober"] | ||
contributors: ["D Hoober"] | ||
published: 2025-08-31 | ||
keywords: ['nagios', 'nagios Core','monitoring','debian 12','ubuntu 22.04', "server health", "nagios plugins'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keywords: ['nagios', 'nagios Core','monitoring','debian 12','ubuntu 22.04', "server health", "nagios plugins'] | |
keywords: ["nagios", "nagios Core", "monitoring", "debian 12", "ubuntu 22.04", "server health", "nagios plugins"] |
Created draft of title subject matter based on updates to Debian and Ubuntu:
Updated Metadata
Added contributor onboarding support notes