Page 1 of 1

REST API After upgrade to 5.2.8

Posted: Mon Jul 18, 2016 3:44 pm
by powderbuck
We just upgraded to 5.2.8 and were using the older form of the REST API. We can't get it working in the new version. If we do this:

https://nagiosxi-pgh01.eagleaccess.com/ ... y=p2pmjepq

We get this:

Status Code: 404 Not Found
Connection: close
Content-Length: 325
Content-Type: text/html; charset=iso-8859-1
Date: Mon, 18 Jul 2016 20:31:58 GMT
Server: Apache/2.2.15 (Red Hat)

If this:

https://nagiosxi-pgh01.eagleaccess.com/nagiosxi/api/v1/

{"error":"No API Key provided"}

We also added this to the end of our /etc/httpd/conf.d/ssl.conf

<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>

Any help is appreciated.

Thx.

-D

Re: REST API After upgrade to 5.2.8

Posted: Mon Jul 18, 2016 4:04 pm
by rkennedy
I saw this happening on a test system. The ssl_error_log was showing -

Code: Select all

[Mon Jul 18 15:58:55 2016] [error] [client x] File does not exist: /usr/local/nagiosxi/html/api/v1/system, referer: https://x/nagiosxi/help/api.php
I just tested this, and had to add exactly what you posted right before the </VirtualHost> tag.

For example -

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?req$
</IfModule>
</VirtualHost>
Then, run service httpd restart and try once again. It should be working.

If not, please post your /var/log/httpd/ssl_error_log file, and also your ssl.conf file.

Re: REST API After upgrade to 5.2.8

Posted: Mon Jul 18, 2016 4:53 pm
by rkennedy
For the record, I updated the SSL documentation. You can use the following one liner to make the change to your ssl.conf if it does not already exist. (which it sounds like you already have, this is just for reference)

Code: Select all

sed -i -e '/<\/VirtualHost>/i\<IfModule mod_rewrite.c>' -e '/<\/VirtualHost>/i\RewriteEngine On' -e '/<\/VirtualHost>/i\RewriteCond %{REQUEST_FILENAME} !-f' -e '/<\/VirtualHost>/i\RewriteCond %{REQUEST_FILENAME} !-d' -e '/<\/VirtualHost>/i\RewriteRule nagiosxi/api/v1/(.*)$ /usr/local/nagiosxi/html/api/v1/index.php?request=$1 [QSA,NC,L]' -e '/<\/VirtualHost>/i\</IfModule>' /etc/httpd/conf.d/ssl.conf

Re: REST API After upgrade to 5.2.8

Posted: Tue Jul 19, 2016 6:56 am
by powderbuck
No change, even after moving it inside the virtualhost block.

Upon closer inspection, there was a duplicate SSL/443 setup in nagiosxi.conf, I moved any unique settings from that into ssl.conf and restarted. Looks good now.

:D

Thanks.

Re: REST API After upgrade to 5.2.8

Posted: Tue Jul 19, 2016 9:42 am
by mcapra
Thanks for sharing your solution! Is it alright if we lock this thread and mark the issue as resolved?