JoeZhao

跨出界

Hey, I’m JoeZhao, a software engineer, and a gamer.

Caddy Universal Domain Configuration Guide

From the Automatic HTTPS - Caddy documentation, it is known that Caddy supports configuring wildcard domain formats like *.fun2ex.com.

Referring directly to the documentation, the initial configuration of /etc/caddy/Caddyfile is as follows:

*.fun2ex.com
{
        tls {
            dns dnspod
        }
        root /var/www/html
}

I am using DNSPOD myself, and the specific supported DNS service providers can be directly viewed from the documentation.
Next, we need to set the environment variables for DNSPOD Auth API, and the specific values of the environment variables can be found in Automatic HTTPS - Caddy.

Since I am using systemd to manage the caddy process, we can directly edit the caddy service file:

sudo vim /etc/systemd/system/caddy.service

Find the line Environment=, and add the value of the environment variable. If you want to add multiple variables, separate them with spaces:

; Letsencrypt-issued certificates will be written to this directory.
Environment=CADDYPATH=/etc/ssl/caddy DNSPOD_API_KEY='$id,$hash_key'

Let's restart and try it out:

sudo systemctl restart caddy
sudo systemctl status caddy

To be continued...

  1. Switching from nginx to caddy, making all websites friends with SSL
  2. How to specify an Environment systemd directive containing =? - Ask Ubuntu
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.