picocms / Pico

Pico is a stupidly simple, blazing fast, flat file CMS.
http://picocms.org/
MIT License
3.81k stars 616 forks source link

Caddyfile? #625

Closed geoidesic closed 2 years ago

geoidesic commented 2 years ago

Does anyone have information about how to set up a Caddyfile to work with pico?

I can get the basic index HTML serving with this:

:80 {
        root * /var/www/html/pico
        php_fastcgi unix//run/php-fpm/www.sock
        file_server
}

But static files are NOT served (e.g. css). Presumably the .htaccess file needs to have a Caddyfile equivalent, but how?

[UPDATE:] on further investigation, this should work but for some reason Picocms is referencing files with the wrong URL.

I think this is because the URL's are not quite as caddy expects. For example, in the source of the page generated by the CMS is this:

   <link rel="stylesheet" href="https://www.argital.info:80/themes/default/css/style.css" type="text/css" />
    <link rel="stylesheet" href="https://www.argital.info:80/themes/default/css/droidsans.css" type="text/css" />
    <link rel="stylesheet" href="https://www.argital.info:80/themes/default/css/fontello.css" type="text/css" />

However it is the :80 that's breaking things. If I take that URL and remove the :80, I can browse to it, e.g.

https://www.argital.info/themes/default/css/fontello.css

I don't know what's adding the :80 but it's definitely not Caddy that's doing that. Any idea how to make it stop?

geoidesic commented 2 years ago

This provided some clues: https://github.com/picocms/Pico/issues/486

And the solution was to install Caddy server v2.5 (as this behaviour was due to a bug in earlier versions).

mayamcdougall commented 2 years ago

Hi there. 👋🏻

The port number issue also creeps up a lot when using Pico in a reverse-proxy environment, since Pico has trouble determining what its base_url should be.

If you have any more trouble with it, you can try specifying your base_url in config.yml (eg base_url: https://example.com). You should see the port number disappear as it's probably just a side effect of Pico trying to determine the correct url (though, that's usually for ports other than 80).

Getting some Caddy examples in the Docs is something I'd like to do in the future too. It sounds like you've got it working for now (minus the base_url issue).

Just keep in mind that in our Apache and Nginx examples, we deny public access to sensitive folders, like config, plugins, etc. This should be possible with Caddy as well, I just don't have any examples to link you to at the moment. 😓

Anyway, let me know if you have any further issues. I'm usually pretty on top of things here, though I've been a bit sluggish lately. 😅