You should try curl http://localhost. Port 2019 is the admin API. Your config specifies localhost which by default will listen on ports 80 and 443 (i.e. http:// and https://)
This is incorrect, you need to do root * /var/www. In Caddy v2, the first argument of most directives is read as a matcher. In this case, since the first argument starts with / then it’s assumed to be a path matcher. Instead, you need to tell the root directive to use * as your matcher instead (i.e. match any request).
If that still doesn’t fix it, please be more specific – give us the full Caddyfile config you used, the command you used to run Caddy, the output of curl -v <url> and the exact commit hash you built from.
Ah I think I figured out your problem - when you use localhost as your site label, Caddy enables both HTTP and HTTPS, and adds an HTTP->HTTPS redirect. By default, curl doesn’t follow redirects, so you don’t see the final page. Instead, you can do curl -L http://localhost or curl https://localhost.
@francislavoie that did it ! Thanks. I will gradually add my directives from caddy v1, one by one, and try to restore my web site. BTW, what are the main advantages of v2 vs v1?
Caddy v2 is a complete rewrite and redesign from v1 (from scratch, pulling features back in one by one).
Now, Caddy uses JSON as the main configuration language, and provides Caddyfile as a translation layer to JSON. This makes configuration much more flexible.
The design of Caddy v1 had a lot of shortcomings that made it very difficult or impossible to implement new features, and had limited flexibility because of it.
using the import directive to import conf file with directives shared by multiple domains: done
A couple of remarks though:
Just for clarity, the useradd and groupadd commands in the Install section should be prefixed with sudo as these commands require root privilege.
I am using as this caddy.service file for systemd. Also for clarity reasons, the doc should maybe also mention to make sure that “caddy” user has access to the php-fpm socket otherwise systemd will launch caddy server with no error, but the php files will never be served. Took me some time before I checked syslog where the socket permission error was thrown.
could not find the import directive in the v2 directives list, but it works.
Technically it’s not a directive because it’s a special keyword to deal with code reuse. That said, I agree it probably should be in the directives list.