What is the best way to use a single rpi to use pi-hole and host a public website?

I have installed pi-hole + openvpn on my rpi 4 and am very please about the setup. Now I would like to simultaneously like to use the rpi for hosting a public personal website, referred to by the domain www.myname.com and most likely containing just some basic html.

What is the way to go to achieve this? I don’t really care if my web page uses lighttpd, apache, nginx or something else entirely. The problem with using lighttpd is that opening port 80 on my router opens the pihole admin panel to the whole internet. I can also install apache and let it listen to another port, but don’t think it is possible to let a domain name refer to a port other than 80.

I should point out that I have a programming background but am a bit of a Linux / networking novice. I also searched some old threads, some of which describe similar issues but none has answered the question above. Any advice is very welcome, many thanks in advance.

Why not move Pi-hole’s lighttpd to a different port and spawn an apache instance on 80 ?

I suppose it’s the simplest option, but this is not officially supported (see How to edit external.conf to override lightpd.conf default port). It means that I have to change the port back after every pihole update.

Any other options?

You could add another IP and bind the lighttpd/nginx/apache2 daemons to the different IP’s:

But I wouldn’t run a DNS service for my private network AND a public web service on the same machine.
One mistake and hackers are in having control over your DNS doing man in the middle etc.
The public web service needs to be in some sort of DMZ!

Thanks, that seems good advice.

For future reference, I also found this post concerning running a webserver and pi-hole on the same machine which seems similar: https://rafaelc.org/blog/running-a-web-server-while-using-pi-hole/

I’ll look into it in some more detail and report back when I find the time.