Continuing the discussion from Running Discourse with Caddy Server:
I’m coming over from a misbehaving nginx + wp + discourse scenario. Since Nginx reverse proxy was throwing weird errors on the Discourse side, I was lured here by rumors of easy configuration files. Buuuut, I guess easy is relative.
Caddy: (h/t @matt & @abiosoft)
Discourse: on forums.example.com (h/t @Falco)
WordPress: 502 bad gateway on wp.example.com via Cloudflare
Portainer: 502 bad gateway on port.example.com via Cloudflare
Caddy / Docker
I suspect, due to Cloudflare (among other things), that I may need a custom build to include some plugins. Following the abiosoft/caddy description, I was looking at something like this:
docker build --build-arg \
plugins=realip,git,cloudflare,upload \
github.com/abiosoft/caddy-docker.git
In fact, I did that build once, but quit when I realized PHP wasn’t in the mix. I guess I also need the :php flag on the image. For what’s working now, I used Falco’s docker run command, but with the :php flag (and proper email).
- Is there a way to build from abiosoft’s image to get PHP + the plugins?
- Do I need realip and cloudflare to use Cloudflare?
Ports
I grabbed a screenshot from Portainer, mainly because it’s more compact than my terminal:
Caddyfile
forums.example.com {
#Discourse
proxy / unix:/sock/nginx.http.sock {
transparent
}
}
port.example.com {
#Portainer
proxy / 9000:80 {
transparent
}
}
wp.example.com {
#Wordpress
proxy / 80:80 {
transparent
}
}
Since I suspect my Caddyfile is wrong AND I need plugins, getting help on either half of the equation would allow me to dig into the remaining variables. The Caddyfile WP example leads me to believe I still have some work to do beyond just getting the proxy bit right.
WordPress
Whoa, so many options between alpine, fpm, and the various combinations. Is there one image I should be flagging with a better chance it will play nicely with everything else?
I should also say that Portainer isn’t really crucial to this endeavor. I installed it to see if it might help troubleshoot after the other stuff wasn’t working. It seems like that subdomain is suffering from the same problem as WP, so I’d guess the solution for both of them would be similar.
[Update: Soved]
This was basically solved by @Whitestrake in post 2. The files in the “Solved” post below are 100% functional in terms of the goals of the topic. Wordpress (Apache) + Discourse + Caddy + Cloudflare work in that configuration. It is easy to spin up multiple Wordpress sites with that same configuration simply by repeating the Wordpress and MariaDB section in docker-compose.yml.
[Addendum]
The ultimate goal of having this work with a slim Wordpress Docker image based on Alpine and PHP-FPM is currently not 100%. The discussion below the “Solved” post relates to attempts to get that working.