Add custom route?

What should be the best practice to add a custom route to Matomo - like adding a /health endpoint?

The simple way is to proxy it with nginx, but I rather do it direct in Matomo.