HTTPS for Wildcard Subdomains and Main Domain

1. Caddy version (caddy version):

v2.3.0 h1:fnrqJLa3G5vfxcxmOH/+kJOcunPLhSBnjgIvjXV/QTA=

2. How I run Caddy:

First installed caddy with following commands as root user. Therefore, I did not use sudo in following commands.

sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
curl -1sLf '' | sudo apt-key add -
curl -1sLf '' | sudo tee -a /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install caddy

After installation, caddy service ran which I verified by typing caddy at the command prompt.

a. System environment:

Ubuntu 20.04.2 LTS (GNU/Linux 5.4.0-65-generic x86_64)

b. Command:

Using caddy service that started right after installation. I run following command after every Caddyfile update

caddy reload

c. Service/unit/compose file:

I'm not sure about this, sorry. I'm running uBuntu installation. 

d. My complete Caddyfile or JSON config:, * {
    root * /var/www/html
    php_fastcgi unix//run/php/php8.0-fpm.sock

        log {
                output file /var/log/caddy/access.log
                format console

3. The problem I’m having:

I’m developing a multi-tenant app that lets users map their subdomains and domains to relevant subdomain hosted on my server. That is -

  • https://<user-created-subdomains>
  • https://<user-subdomain>

… running my application as backend.

However, as @matt said, this is going to be a super-advanced configuration. I’d therefore like to start with a much simpler configuration that lets me have https enabled on and *; so that I can have any subdomain delivered via HTTPS.

4. Error messages and/or full log output:

I could not get any log entries in the /var/log/caddy/access.log. I tried changing the owner and group of the access.log file to caddy and also tried running systemctl restart systemd-journald.service command as described in Caddy is not generating any logs when launched as a service · Issue #3943 · caddyserver/caddy · GitHub . However, I still do not get any log entries.

Looks like the first issue I need to solve is to get the access logs.

5. What I already tried:

I’ve created an /var/www/html/index.php file and also installed php8. I’ve tried multiple configurations of Caddyfile and my latest attempt is mentioned above.

WIth above configuration, I got working. However, can’t get https://<subdomain> working. It throws following error in browser- sent an invalid response.

6. Links to relevant resources:

This topic was automatically closed after 30 days. New replies are no longer allowed.