Virtual host declaration with Caddyfile

If we want to serve multiple subdomains on the same server the Caddyfile may look as follow:

www.example.com {
   root /webspace/www
   import common.conf
}
forum.example.com {
    root /webspace/forum
    import common.conf
}

Within the declaration of the URL we need only the parts which are only for the sub domain.

the file common.conf may look as follow:

gzip
fastcgi / /run/php/php7.0-fpm.sock php {
        index index.php
}

Are you asking for a “common” area in the Caddyfile? i.e. block inheritance?

No common is a file containing configuration common for all virtual hosts declared within the main configurations file. My post may be seen as example.

1 Like

See:
https://caddyserver.com/docs/import
https://caddyserver.com/docs/caddyfile#snippets

I believe that may be what you wish to use.

1 Like