Guide to get Caddy & SELInux to play together

1. Caddy version (caddy version):

2.4

2. How I run Caddy:

via systemd

a. System environment:

Rocky LInux 8.4

Hi guys, is there a handy guide to getting caddy to play with SELinux (for use on Centos, Rocky etc).

I’m sure it’s a not big problem for those experienced with SELinux. But I’ve kept well clear of rpm distros throughout, and SELinux has been a key part of the reason.

I remember, in the early days, getting Nginx to work with SELinux was pretty difficult. But I can see that there are dozens of guides on installing Nginx on RH-based distros.

Anyway, I was forced to migrate one of my sites from Ubuntu to Rocky Linux, and try as I might (well, I gave it a couple of hours of research online), I can’t get the whole thing to make music together.

Mostly, it’s to do with Caddy being kinda unrecognized by SELinux and the program blocking Caddy from access all kinds of folders. Everything results in either a 500 or a 502.

So, I tried installing nginx on the same server using one of the many guides available, and everything works fine. But if I turn off NGINX on the same server and turn on Caddy (both are installed), it gives a 502 error.

Is there a guide to getting SELinux and Caddy working together? I know I can fix this if I dive deep into SELinux terminologies and protocols, but I don’t have a couple of days I can dedicate for this right now. If anyone can write up a short guide, it would be extremely helpful. Like this one for Nginx – https://www.linuxcapable.com/how-to-install-wordpress-with-lemp-nginx-mariadb-and-php-on-rocky-linux-8/