Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Caddy web server fastcgi with virtual hosts

I am trying to configure Caddy FastCGI with multiple virtual hosts. As far as I can tell the following Caddyfile should be working:

gzip
tls [email protected]
errors /var/log/caddy/error.log

header / Strict-Transport-Security "max-age=15768000;"

portal.mydomain.info {
    fastcgi / 127.0.0.1:3000 {
        root /var/www/portal
        ext .php
        index index.php
    }
}

urlf.mydomain.info {
    fastcgi / 127.0.0.1:3001 {
        root /var/www/urlf
        ext .php
        index index.php
    }
}

But Caddy is failing to start with error:

Feb  2 04:33:58 ip-172-31-24-38 caddy[3135]: 2018/02/02 04:33:58 /etc/caddy/Caddyfile:7 - Error during parsing: Unknown directive 'portal.mydomain.info'
like image 671
Justin Avatar asked Dec 06 '25 02:12

Justin


1 Answers

From the Caddyfile tutorial:

The first line of the Caddyfile is always the address of the site to serve.

So you'll need to restructure your Caddyfile so all directives are inside a site definition. Here's a page describing the syntax in more technical (and visual) detail.

like image 82
Matt Avatar answered Dec 11 '25 19:12

Matt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!