The User Manual has a section on integrating the
calibre content server with other servers. That seems like the best way to get what you need. Do any auth or logging from Apache, and then either reverse proxy to calibre-server itself or host it in process.