Here are some notes about how I got my test Discourse instance running with Caddy Server.
Cool stuff about Caddy:
-
They use Discourse
-
Free SSL with Let’s Encrypt
-
HTTP2 and QUIC out of the box
-
Easier to configure than nginx
Cons:
- Not as battle tested as apache, nginx and cia.
How To
Preparing Discourse
First, you need to apply this changes to your app.yml
:
templates:
- "templates/postgres.template.yml"
- "templates/redis.template.yml"
- "templates/web.template.yml"
- "templates/web.ratelimited.template.yml"
- "templates/web.socketed.template.yml" # <<<----- THIS IS NEW
## Let this two commented out
# - "templates/web.ssl.template.yml"
# - "templates/web.letsencrypt.ssl.template.yml"
## Let this two commented out
expose:
# - "8080:80" # http
# - "443:443" # https
env:
## This should be commented out too
#LETSENCRYPT_ACCOUNT_EMAIL: mymail@gmail.com
Preparing Caddy
In the spirit of Discourse, let’s put Caddy in a Docker image too
First prepare with:
mkdir /var/caddy
nano /var/caddy/Caddyfile
Add the following to the Caddyfile
forum.example.com # your domain here
proxy / unix:/sock/nginx.http.sock {
transparent
}
Save and exit.
Let’s test
Now you need to rebuild Discourse:
/var/discourse
./launcher rebuild app
And then run Caddy:
docker run -d \
-v /var/caddy/Caddyfile:/etc/Caddyfile \
-v /var/caddy:/root/.caddy \
-v /var/discourse/shared/standalone:/sock \
-p 80:80 -p 443:443 \
-p 80:80/udp -p 443:443/udp \
--restart=always \
--name caddy \
--entrypoint "/usr/bin/caddy" \
abiosoft/caddy -quic -email MYEMAILHERE@gmail.com -agree --conf /etc/Caddyfile --log stdout
After all, your forum should be avaliable at your domain, using SSL + HTTP2 + QUIC. You can’t more hipster than that.