I am running Nagios Core 4.0.8 in my environment and I am looking to find a way to change the default url from https://example.com/nagios to https://example.com. Is there a way one can do that?
2 Answers
You will need to edit the cgi.cfg file for Nagios.
vim /usr/local/nagios/etc/cgi.cfg
Change
url_html_path=/nagios
tourl_html_path=/
Edit nagios.conf:
Change
ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"
toScriptAlias /cgi-bin "/usr/local/nagios/sbin"
Comment out the line
Alias /nagios "/usr/local/nagios/share"
and then add belowDocumentRoot /usr/local/nagios/share
Add the following at top of the configuration:
<VirtualHost *:80>
ServerName status.example.com
and add
</VirtualHost>
at the bottom.Edit your
/usr/local/nagios/share/config.inc.php
file:Change
$cfg['cgi_base_url']='/nagios/cgi-bin';
to$cfg['cgi_base_url']='/cgi-bin';
Restart Apache and Nagios

- 2,959
- 1
- 20
- 34

- 91
- 1
- 6
-
This is a robust answer. – Adambean Oct 12 '18 at 18:16
-
Thanks, great answer. The **step 3** was __not necessary__ in my case because I let this 2 lines in my Apache VirtualHost : `ScriptAlias /cgi-bin/nagios4 /usr/lib/cgi-bin/nagios4` and `ScriptAlias /cgi-bin /usr/lib/cgi-bin/nagios4` – mhoareau Oct 10 '19 at 05:20
If you are using Apache to serve your Nagios page you can do different things. Apache configuration files are usually located in /etc/apache2/.
Probably your DocumentRoot is set to /var/www, so you can create a file named "index.html" and place this code inside it to redirect to /nagios URL:
<META HTTP-EQUIV="Refresh" Content="0; URL=/nagios">
You can also edit your nagios apache config (probably /etc/nagios/apache2.conf...) or apache config /etc/apache2/*.conf and add:
RedirectMatch ^/$ /nagios
If you don't like these methods there are more, just think of it as using Apache to redirect, not like a Nagios thing.

- 246
- 1
- 4