4

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?

Ura718
  • 371
  • 2
  • 6
  • 13

2 Answers2

8

You will need to edit the cgi.cfg file for Nagios.

  1. vim /usr/local/nagios/etc/cgi.cfg

    Change url_html_path=/nagios to url_html_path=/

  2. Edit nagios.conf:

    Change ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin" to ScriptAlias /cgi-bin "/usr/local/nagios/sbin"

    Comment out the line Alias /nagios "/usr/local/nagios/share" and then add below

    DocumentRoot /usr/local/nagios/share

    Add the following at top of the configuration:

    <VirtualHost *:80> ServerName status.example.com

    and add </VirtualHost> at the bottom.

  3. 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';

  4. Restart Apache and Nagios

Paxz
  • 2,959
  • 1
  • 20
  • 34
  • 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
3

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.

Xacosta
  • 246
  • 1
  • 4