I've recently started using the check_civicrm script from https://github.com/MegaphoneJon/check_civicrm
It works great and my monitoring is greatly improved. However, on some sites I get a 403 error instead of expected response from CiviCRM. I successfully determined that the earlier 500 errors were due to lack of anonymous permission on "CiviCRM: access AJAX API".
Adding to the mystery is the fact that two of the installations are on the same server. One gives expected output, the other a 403. I assume there is some additional permission required somewhere, but I am at a loss to figure out what.
The Civi log is not particularly edifying either, just telling me Civi\API\Exception\UnauthorizedException: "Authorization failed"
UPDATE: I have dug into the script and see that is is making a POST request to https://sitename.com/civicrm/ajax/api4/System/check. When I visit it in a browser I get a 401 error and the message "Ajax requests can only be issued by javascript clients, eg. CRM.api4()."
.
Any thoughts?