I’ve seen a lot of different ways to create caddyfiles.
But what I don’t get is why some people use https://example.com and some people use only example.com
What is the difference? Does it affect anything?
One accepts only https traffic, while the other one can accept both, http and https. If you have auto_https redirects enabled (default), the second one will also redirect any http traffic for that site to https. I believe the first one won’t do that, because it’s explicitly https only. Or sometimes you want to separate http virtual from https.
Ah, that clarifies it. Thanks for the information.
If I may offer a slight correction:
Caddy enables HTTPS for all sites that qualify. The qualifications changed slightly since Caddy v2 was originally released. Back then, only public domain names could get a cert, but now that Caddy has its own self-maintaining CA built in, even local hostnames and IP addresses can have certificates. So where 127.0.0.1 used to be over plain HTTP, it is now over HTTPS, just as if you typed https://127.0.0.1.
So these days, specifying https:// is almost always unnecessary. The overall behavior is the same in almost all cases. With and without, your site will be served over HTTPS, and will have redirects from HTTP.
Specifying http://, however, has always been, and still is, necessary if you really only want plaintext HTTP for a site.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.