For flexibility you may wish to consider using a golang proxy/edge router. Also useful for https / acme.
There is a solution using traefik here: https://imandrea.me/blog/traefik-custom-404/
This seems to use traefik.http.routers.error-router.
Adam
basex-talk@mailman.uni-konstanz.de