Error w/ localhost - HTTP WARNING: HTTP/1.1 403 Forbidden

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
PhilG
Posts: 286
Joined: Thu Jan 16, 2014 10:24 am

Error w/ localhost - HTTP WARNING: HTTP/1.1 403 Forbidden

Post by PhilG »

Hello:
Using Oracle Enterprise Linux 7.3, latest install of Nagios XI installed (ver. 5.4.11).
First thing I see in the web console is localhost doing a check_http and getting error:
HTTP WARNING: HTTP/1.1 403 Forbidden
I did some checking around and found the following, but they didn't help fix the warning/issue:
1). http://raman-kumar.blogspot.com/2009/12 ... 1-403.html
2). https://serverfault.com/questions/52934 ... 60-seconds
3). https://support.nagios.com/forum/viewto ... en#p201859
4). https://serverfault.com/questions/52183 ... nux/521834

I did some digging around and found that localhost uses:
/usr/local/Nagios/etc/services/localhost.cfg
which has:
define service {
host_name localhost
service_description HTTP
use local-service
check_command check_http

SSH'ed into the new Nagios XI server as root and then ran the following from the command line and result is as follows:
a). /usr/local/nagios/libexec/check_http -H <new_nagiosxi_server_IP>
Result: HTTP WARNING: HTTP/1.1 403 Forbidden

b). /usr/local/nagios/libexec/check_http -H <new_nagiosxi_server_IP> -u "/nagiosxi"
Result: HTTP OK: HTTP/1.1 301 Moved Permanently

c). /usr/local/nagios/libexec/check_http -H <any_website, ex. google.com or internal website we host>
Result: HTTP OK: HTTP/1.1 301 Moved Permanently


SOLUTION: "Re-engineered" NagiosXI localhost check_http temporarily until a possible better "fix" is identified.
1). Stopped Apache and NagiosXI on server
2). Edited the "/usr/local/nagios/etc/services/localhost.cfg" file:
a). Changed the following:

define service {
commented out: use local-service
added: use xiwizard_website_http_service

added: contacts nagiosadmin

commented out: check_command check_http
added: check_command check_xi_service_http! -f ok -I <new_nagiosxi_server_IP> -u '/nagiosxi' -p 80



Either I leave this, or wait for a solution from Nagios XI tech team, or delete the localhost check, since if I can connect/access the Nagios XI web console, then Apache is working at least.
Newbie '14
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: Error w/ localhost - HTTP WARNING: HTTP/1.1 403 Forbidde

Post by npolovenko »

Hello,@PhilG. Thanks for your input! You might have some firewall restrictions in your organisation that interfere with check_http. But first, lets try the following:

SSH into the Nagios XI and run this command:

Code: Select all

/usr/local/nagios/libexec/check_http -I 127.0.0.1 
And this command:

Code: Select all

/usr/local/nagios/libexec/check_http -H <new_nagiosxi_server_IP> -u "/nagiosxi/"
Finally, this command:

Code: Select all

/usr/local/nagios/libexec/check_http -H www.google.com
When I ran check_http against google.com I also got "Moved Permanently", but then I ran it with www and got the right result.
Please provide us with the output. Thank you.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
PhilG
Posts: 286
Joined: Thu Jan 16, 2014 10:24 am

Re: Error w/ localhost - HTTP WARNING: HTTP/1.1 403 Forbidde

Post by PhilG »

npolovenko wrote:Hello,@PhilG. Thanks for your input! You might have some firewall restrictions in your organisation that interfere with check_http. But first, lets try the following:

SSH into the Nagios XI and run this command:

Code: Select all

/usr/local/nagios/libexec/check_http -I 127.0.0.1 
And this command:

Code: Select all

/usr/local/nagios/libexec/check_http -H <new_nagiosxi_server_IP> -u "/nagiosxi/"
Finally, this command:

Code: Select all

/usr/local/nagios/libexec/check_http -H www.google.com
When I ran check_http against google.com I also got "Moved Permanently", but then I ran it with www and got the right result.
Please provide us with the output. Thank you.


I'm redoing the server at this time and am leaving home for the day in a few minutes. It appears that what I noted earlier and applied may have affected with getting back on the Nagios XI web console, so I reverted to my base server VM snapshot and ran the NagiosXI full install again. *sigh*

To answer the issue about a firewall problem, I do not believe so. If there was a firewall issue, then I would have received errors or not have been able to check any "external" sites. The new server is not running IPTables/local firewall, too. The problem is ONLY occurring with localhost attempting to check_http on local server Apache/http.


Install completed and got back on Nagios XI console. I have not added/deleted/modified anything yet on the server and in the Nagios XI web console (other than the Admin password and time). Here's the information you wanted from the server command line:
1). /usr/local/nagios/libexec/check_http -I 127.0.0.1
Result: HTTP WARNING: HTTP/1.1 403 Forbidden

2). /usr/local/nagios/libexec/check_http -H <new_nagiosxi_server_IP> -u "/nagiosxi/"
Result: HTTP OK: HTTP/1.1 301 Moved Permanently

3). /usr/local/nagios/libexec/check_http -H google.com
Result: HTTP OK: HTTP/1.1 301 Moved Permanently

4). /usr/local/nagios/libexec/check_http -H http://www.google.com
Result: HTTP OK: HTTP/1.1 200 OK

5). /usr/local/nagios/libexec/check_http -H <FQDN of "internally" hosted website on a different Apache server>
Result: HTTP OK: HTTP/1.1 200 OK
Newbie '14
PhilG
Posts: 286
Joined: Thu Jan 16, 2014 10:24 am

Re: Error w/ localhost - HTTP WARNING: HTTP/1.1 403 Forbidde

Post by PhilG »

I believe I have this figured out. A piece of information from the following gave me a clue:
https://stackoverflow.com/questions/236 ... -forbidden

My OEL 7.3 Apache web server template contained a "default" Virtual Host file that had the document root to "/var/www/html", which is owned by "root" user and group. Obviously, "localhost" does not have the privilege.

SOLUTION: Removed "default" Virtual Host on server and restarted Apache and Nagios. Now the localhost check_http is fine.

Once again, I needed to refer to the term "BASE" (bare bones) server install, step back, and then take a little time to reflect what exists and check things over more closely.

You may lock this post.
Newbie '14
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Error w/ localhost - HTTP WARNING: HTTP/1.1 403 Forbidde

Post by lmiltchev »

Thanks for the feedback, PhilG!
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked