New REST API not working

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
sib
Posts: 111
Joined: Thu Dec 11, 2014 8:06 am

New REST API not working

Post by sib »

Hi

I just upgraded to 5.2.1 but the REST API does not work

When I call

https://lbnss22/nagiosxi/api/v1/objects ... y&pretty=1

I get the following error
Looking into http error log it says
File does not exist: /usr/local/nagiosxi/html/api/v1/system, referer: https://lbnss22/nagiosxi/help/api.php?&=
Looks like the reqrite rule does not work. Here the nagiosxi.conf of httpd

Code: Select all

<Directory "/usr/local/nagiosxi/html">
#  SSLRequireSSL
   Options None
   AllowOverride None
   Order allow,deny
   Allow from all
#  Order deny,allow
#  Deny from all
#  Allow from 127.0.0.1
#   AuthName "Nagios XI"
#   AuthType Basic
#   AuthUserFile /usr/local/nagiosxi/etc/htpasswd.users
#   Require valid-user
</Directory>

Alias /nagiosxi "/usr/local/nagiosxi/html"

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule nagiosxi/api/v1/(.*)$ /usr/local/nagiosxi/html/api/v1/index.php?request=$1 [QSA,NC,L]
</IfModule>
There is quite some config files in the httpd config directory. Maybe from previous stuff

Code: Select all

# ll /etc/httpd/conf.d/
total 76
-rw-r--r--. 1 root   root     330 Oct  3  2012 mrtg.conf
-rw-r--r--. 1 root   root    1010 Dec 18  2014 nagios.conf
-rwxrwxrwx  1 root   root     601 Nov 10 14:04 nagiosmobile.conf
-rw-r--r--. 1 root   root     427 Nov 10 14:53 nagiosql.conf
-rw-r--r--. 1 root   root     598 Nov 11 14:22 nagiosxi.conf
-rw-r-----  1 apache apache  2148 Sep 12 08:49 nagvis.conf
-rw-r-----  1 apache apache  2435 Sep 12 08:47 nagvis.conf.1442040462
-rw-r-----  1 apache apache  2435 Sep 12 08:49 nagvis.conf.1442040560
-rw-r--r--. 1 root   root     344 Dec 18  2014 nrdp.conf
-rw-r--r--  1 root   root    1796 Apr 17  2014 perl.conf
-rw-r--r--. 1 root   root     674 Oct 23  2014 php.conf
-rw-r--r--. 1 root   root     392 Aug 15  2014 README
-rw-r--r--. 1 root   root   10064 Nov 11 13:57 ssl.conf
-rw-r--r--. 1 root   root    9473 Dec 18  2014 ssl.conf.nagiosxibackup
-rw-r--r--. 1 root   root     299 Aug 15  2014 welcome.conf
Happy to delete everything except files needed for nagiosxi
jomann
Development Lead
Posts: 611
Joined: Mon Apr 22, 2013 10:06 am
Location: Nagios Enterprises

Re: New REST API not working

Post by jomann »

Hello,

You have to add the following to /etc/httpd/conf.d/ssl.conf

Code: Select all

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule nagiosxi/api/v1/(.*)$ /usr/local/nagiosxi/html/api/v1/index.php?request=$1 [QSA,NC,L]
</IfModule>
The new PDF guide on setting up SSL also shows it here https://assets.nagios.com/downloads/nag ... s%20XI.pdf
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
sib
Posts: 111
Joined: Thu Dec 11, 2014 8:06 am

Re: New REST API not working

Post by sib »

Thanks that did the trick
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: New REST API not working

Post by tmcdonald »

I'll be closing this thread now, but feel free to open another if you need anything in the future!
Former Nagios employee
Locked