CodeIgniter 4 & Zabbix Checks

I am using my Zabbix server to track for issues with various web sites (namely to alert if a site goes offline). I then recently upgraded CodeIgniter, which powers my main site, and got alerted to ‘Site Down’, despite the site being up, accessible, responsive, and returning a 200 OK. Testing with curl, however, resulted in the 404 as reported by Zabbix:

# curl -IL https://armware.net/
HTTP/2 404
date: Sun, 25 Feb 2024 15:52:28 GMT
server: Apache
cache-control: no-store, max-age=0, no-cache
content-type: text/html; charset=UTF-8
via: e3s

After a lot of digging through the documentation, forums, and other usual spots I found only a few other reports of this with zero answers on how to resolve it. So I started digging.

The servers web logs gave a clue; Zabbix is making a HEAD request:

1<server ip redacted>7 - - [25/Feb/2024:17:31:30 +0000] "HEAD / HTTP/1.1" 404 - "-" "Zabbix"

Which is the same that curl -I does. Testing this, let’s try a GET request through curl. Spoiler: it worked, and we received a 200 OK. So now, the main question – how do we get CodeIgniter to reply to the HEAD requests with 200 OK? Add a route to ‘app/Config/Routes.php’:

$routes->head('/', 'Home::index');

The alert cleared, and we can double confirm with another run of curl:

# curl -IL https://armware.net/
HTTP/2 200
date: Sun, 25 Feb 2024 17:27:47 GMT
server: Apache
cache-control: no-store, max-age=0, no-cache
content-type: text/html; charset=UTF-8
via: e1s