As you've observed, Pi-hole comes with its own web server lighttpd.
As lighttpd is included in Pi-hole's image, it would always be active to serve Pi-hole's web UI if you would run your Pi-hole as a Docker container.
This would conflict over port 80/HTTP with any other webserver on the same machine.
To coexist with another webserver like Caddy, you'd have the option of mapping one of the containers to a different port with Docker, or to configure your Pi-hole container for a different WEB_PORTenvironment variable.
I've configured Caddy to be served on port 80 while Lighthttpd runs on another port. Need to say that any upgrade to Pi-Hole does reset my custom Lighthttpd.conf (just setting the port)
/etc/lighttpd/lighttpd.conf should not be edited at all, as per disclaimer at the top of that file:
###############################################################################
# FILE AUTOMATICALLY OVERWRITTEN BY PI-HOLE INSTALL/UPDATE PROCEDURE. #
# ANY CHANGES MADE TO THIS FILE AFTER INSTALL WILL BE LOST ON THE NEXT UPDATE #
# #
# CHANGES SHOULD BE MADE IN A SEPARATE CONFIG FILE: #
# /etc/lighttpd/external.conf #
###############################################################################
Would you run a dockered or a bare metal Pi-hole?
For a Pi-hole Docker container, you should make use of the options I've mentioned above.
For a bare metal Pi-hole, put your custom configuration in external.conf, and apply jfb's suggestion as required.
A possible approach to have your additional webserver work with both kinds of Pi-hole may consider to have Caddy redirect, rewrite or proxy the URLs to lighttpd's port.
Right. I applied the change to external.conf as indicated.
However, it does not fix the problem with both problem messages. This on caddy (bare metal or docker) in the Dashboard:
Undefined array key "SERVER_ADDR" in /var/www/html/admin/scripts/pi-hole/php/auth.php
And this into the Long Term Data > Query Log in lighttpd bare metal
Undefined array key "client_id" in /var/www/html/admin/api_db.php on line 127
Give this second error is within the bare metal default installation, do I need to create another thread in the help since this is not a customized installation?
Note that lighttpd is the only web server officially supported by Pi-hole.
So you are running a bare metal Pi-hole with its lighttpd web server active and configured for a custom port.
In that case, Pi-hole's UI should be available at http://pi.hole:<custom-port>/admin - there would be no immediate need to involve a different webserver.
Nevertheless, as mentioned, based on your intention, you should be able to configure your Caddy webserver to point HTTP requests to be handled by lighttpd's port instead of having Caddy handling them.
This would essentially be a question of how to configure Caddy, so you may want to consider consulting Caddy's community support as well.
From your description, your second observation may constitute a different issue altogether (click for quote details):
Yeah, my intention was to only use Caddy. I only maintaned and ran lighttpd to see if I could reproduce it there. Since I cannot reproduce it on lighttpd, I found this to be a Caddy problem on not populating the $_SERVER array in PHP.
This is the print_r function on $_SERVER in lighttpd