REST API Not Found

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
ciaranrh
Posts: 37
Joined: Thu Jul 09, 2015 3:54 pm

REST API Not Found

Post by ciaranrh »

Hello,

I've recently enabled my NagiosXI implementation to use SSL via the documentation here: https://assets.nagios.com/downloads/nag ... s%20XI.pdf

When attempting to access the REST API via HTTPS I now get a 404 not found - when I access the REST API via HTTP I get the expected return.

Here's the error's I'm seeing when attempting to access via HTTPS:

Code: Select all

[root@nagiosxidev ~]# tail -25 /var/log/httpd/ssl_error_log
[Fri Jan 06 13:58:29 2017] [error] [client x.x.x.x] File does not exist: /usr/local/nagiosxi/html/api/v1/system

[root@nagiosxidev ~]# tail -25 /var/log/httpd/ssl_access_log
x.x.x.x - - [06/Jan/2017:13:58:29 -0500] "GET /nagiosxi/api/v1/system/status?apikey=noiqt6hr&pretty=1 HTTP/1.1" 404 321
When accessing via HTTP I see the following:

Code: Select all

[root@nagiosxidev ~]# tail -25 /var/log/httpd/access_log
x.x.x.x - - [06/Jan/2017:14:10:13 -0500] "GET /nagiosxi/api/v1/system/status?apikey=noiqt6hr&pretty=1 HTTP/1.1" 200 990 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:50.0) Gecko/20100101 Firefox/50.0"
Considering in both cases the GET request points to the same URL

Code: Select all

  /nagiosxi/api/v1/system/status?apikey=noiqt6hr&pretty=1 
I'm at a loss to explain why it seems Apache is tripping up with HTTPS.

Thanks for any input!
Last edited by dwhitfield on Mon Jan 09, 2017 12:31 pm, edited 1 time in total.
Reason: marking with green check mark
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: REST API Not Found

Post by mcapra »

Can you share the output of the following command:

Code: Select all

grep -R '' /etc/httpd/conf.d/*
Former Nagios employee
https://www.mcapra.com/
ciaranrh
Posts: 37
Joined: Thu Jul 09, 2015 3:54 pm

Re: REST API Not Found

Post by ciaranrh »

Please see attached.
You do not have the required permissions to view the files attached to this post.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: REST API Not Found

Post by ssax »

Please edit your /etc/httpd/conf.d/ssl.conf and change this:

Code: Select all

</VirtualHost>
<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>
To this:

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>
</VirtualHost>
Then restart apache and test:

Code: Select all

service httpd restart
Thank you
ciaranrh
Posts: 37
Joined: Thu Jul 09, 2015 3:54 pm

Re: REST API Not Found

Post by ciaranrh »

Oh man, that was the trick. I can't believe I missed that, thanks a lot of the help :D.
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: REST API Not Found

Post by dwhitfield »

ciaranrh wrote:I can't believe I missed that, thanks a lot of the help :D.
No problem! Sometimes it just takes a fresh set of eyes.

I'm going to go ahead and lock this one up.
Locked