Page 1 of 1

Nagios core not running, service ist started

Posted: Fri Feb 14, 2020 2:34 am
by Goulasch
Nagios version Version 4.3.4, HA-Proxy version 1.7.5-2

The service has started.

Nagios is installed on a member server (not DC). A proxy server with HAproxy is set up for remote access.

If the server is accessed directly in the local network, it is shown that the daemon is running and all services can be accessed and displayed.
If access is remote, the request is forwarded to the same member server via a HAproxy. Then the Nagios message (Nagios Core) "Not running" appears.

A trace showed that with local access
ip.of.nagios.server - Administrator [13/Feb/2020:20:24:28 +0100] "GET /nagios3/side.php HTTP/1.1" 200 1438 "https://local.com/nagios3/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:72.0) Gecko/20100101 Firefox/72.0"
ip.of.nagios.server - Administrator [13/Feb/2020:20:24:28 +0100] "GET /nagios3/main.php HTTP/1.1" 200 2885 "https://local.com/nagios3/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:72.0) Gecko/20100101 Firefox/72.0"
ip.of.nagios.server - Administrator [13/Feb/2020:20:24:28 +0100] "GET /nagios3/stylesheets/common.css?4.3.4 HTTP/1.1" 200 2905 "https://local.com/nagios3/side.php" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:72.0) Gecko/20100101 Firefox/72.0"
ip.of.nagios.server - Administrator [13/Feb/2020:20:24:29 +0100] "GET /nagios3/stylesheets/nag_funcs.css?4.3.4 HTTP/1.1" 200 986 "https://local.com/nagios3/main.php" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:72.0) Gecko/20100101 Firefox/72.0"
ip.of.nagios.server - Administrator [13/Feb/2020:20:24:29 +0100] "GET /cgi-bin/nagios/statusjson.cgi?query=programstatus HTTP/1.1" 200 1565 "https://local.com/nagios3/main.php" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:72.0) Gecko/20100101 Firefox/72.0"
and with remote access
ip.of.haproxy.server - Administrator [13/Feb/2020:20:23:55 +0100] "GET /nagios/ HTTP/1.1" 200 4403 "-" "Mozilla/5.0 (iPhone; CPU iPhone OS 13_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.4 Mobile/15E148 Safari/604.1"
ip.of.haproxy.server - Administrator [13/Feb/2020:20:23:56 +0100] "GET /nagios/main.php HTTP/1.1" 200 2833 "https://remote.com/nagios/" "Mozilla/5.0 (iPhone; CPU iPhone OS 13_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.4 Mobile/15E148 Safari/604.1"
ip.of.haproxy.server - Administrator [13/Feb/2020:20:23:56 +0100] "GET /nagios/side.php HTTP/1.1" 200 1539 "https://remote.com/nagios/" "Mozilla/5.0 (iPhone; CPU iPhone OS 13_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.4 Mobile/15E148 Safari/604.1"
ip.of.haproxy.server - Administrator [13/Feb/2020:20:23:56 +0100] "GET /nagios/?query=programstatus HTTP/1.1" 200 1022 "https://remote.com/nagios/main.php" "Mozilla/5.0 (iPhone; CPU iPhone OS 13_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.4 Mobile/15E148 Safari/604.1"
There is a difference in the last "GET" of the path but I have no explanation for it.

Here is an excerpt from haproxy.cfg (access is always only via SSL):
...
frontend https-in
bind *:443 ssl crt /etc/haproxy/cert/haproxy.pem
reqadd X-Forwarded-Proto:\ https

# Define hosts: criteria subdir
acl host_nagios path_beg -i /nagios
acl host_nagios path_beg /nagios
acl host_nagios path_beg /cgi-bin/nagios
.....
use_backend nagios_servers if host_nagios
.....
backend nagios_servers

server nagios local.nagios.server:443 ssl verify none check
...
### End manual additions - proxy section
Tracing the log of the HAproxy shows, that only the backend "nagios_servers" is involved (as expected).

Because the only difference between local and remote access seems to be the HAproxy, I suspect that something is generally wrong with the URL, the path or the header (in total) and/or what needs to be changed so that the remote access is also successful.

Any help is appreciated.

Re: Nagios core not running, service ist started

Posted: Fri Feb 14, 2020 1:57 pm
by benjaminsmith
Hello @Goulasch,

First of all, thanks for joining the Nagios Support Forum and using Nagios Core. One thing to review is a curl command from the remote access host to the Nagios Server.

Code: Select all

curl -k -L -v https://<ip address>/nagios
Proxies can be set up but we don't have any specific documentation regarding the process. I would also recommend reviewing the documentation for HA PRoxy for help.

Re: Nagios core not running, service ist started

Posted: Fri Feb 14, 2020 4:56 pm
by Goulasch
any idear to use curl remote, if a proxy is the only gateway from/to remote ?
Proxies can be set up but we don't have any specific documentation regarding the process.
You are not alone; same to HAproxy :-)

Re: Nagios core not running, service ist started

Posted: Sat Feb 15, 2020 9:29 am
by Goulasch
which Nagios program/script decide whether to use

Code: Select all

status.cgi 
or

Code: Select all

statusjson.cgi 
and under which condition ?

Re: Nagios core not running, service ist started

Posted: Sun Feb 16, 2020 12:52 pm
by Goulasch
Found the issue !

Changed the cgi-path in the ".../config.inc.php" file in the www-directory of Nagios from

Code: Select all

$cfg['cgi_base_url']='/cgi-bin/nagios';
to

Code: Select all

$cfg['cgi_base_url']='/nagios/cgi-bin';
which solved the problem with the remote access via an HAproxy

Re: Nagios core not running, service ist started

Posted: Mon Feb 17, 2020 7:43 am
by scottwilkerson
Great!

Locking thread