Page 1 of 1

REST API Not Found

Posted: Fri Jan 06, 2017 2:16 pm
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!

Re: REST API Not Found

Posted: Fri Jan 06, 2017 2:19 pm
by mcapra
Can you share the output of the following command:

Code: Select all

grep -R '' /etc/httpd/conf.d/*

Re: REST API Not Found

Posted: Fri Jan 06, 2017 3:06 pm
by ciaranrh
Please see attached.

Re: REST API Not Found

Posted: Fri Jan 06, 2017 3:12 pm
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

Re: REST API Not Found

Posted: Mon Jan 09, 2017 12:27 pm
by ciaranrh
Oh man, that was the trick. I can't believe I missed that, thanks a lot of the help :D.

Re: REST API Not Found

Posted: Mon Jan 09, 2017 12:30 pm
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.