Hi,
I’m trying to test out whether I can get Kirby 3 to run on the Caddy web server, as I am currently running a Kirby 2 website through Caddy and want to upgrade. Do you provide an example Caddyfile (like .htaccess but for Caddy), as I am unable to access the panel with my current Caddyfile which worked for my Kirby 2 setup. I am using a slightly modified version of the Caddyfile example that is now 2 years old from https://github.com/caddyserver/examples/tree/master/kirby, and I understand that Kirby 3 supports Caddy as a web server as stated in this page: https://getkirby.com/docs/guide/installation#requirements
This is a very basic Kirby 3 Caddyfile for a local staging installation:
Do not use it in production!
The rewrite rules should be the lines you are interested in.
In this Caddyfile, I suppose the server use php-fpm 7.2 with unix socket.
Php errors are output directly in your browser.
localhost:2019 {
tls off
# PHP-FPM with Unix socket
fastcgi / /run/php/php7.2-fpm.sock php
log stdout
errors visible
rewrite / {
to {path} {path}/ /index.php?{query}
}
}
hi @gillesvauvarin & @dli417!
how would you approach using caddy for a production environment?
I’m thinking about whether it would be smart to create an apache/php container with docker-compose that i would reverse-proxy using caddy, because i have other apps running on the server as well…
I just posted this Caddy v2 Caddyfile (with the help of the people on the Caddy forum) for Kirby 2 and Kirby 3 and am using it locally on my Mac, its’ modular and so easily configurable and it may help… seems to work well.
I am curious as well. What is it that is missing to make any of this usable for production? Just looking at the warning not to use the caddyfile in it’s current state for production. I don’t know anything about the configurations myself.
I was looking at it from someone that doesn’t know how to run the server side to get Kirby running. The beginning of this topic had a warning not to use on a production server so it made me wonder what settings for the config file were needed to configure this properly for exposing traffic to the web.
Honestly considering this if my friend that helps me with NGINX can’t figure out how to get that fixed since this looks like it’s working already.
Yes it seems to work fine locally… I guess the main things you may want to consider for a Caddy live site would be proper SSL certificates rather than the local ones I have in my Caddyfile example. See the Caddy website for more information.
For nginx with K3 we use the file below locally - but again it should be fine for a live site if you add the proper certificate stuff for SSL etc.
# shoes for industry nginx conf for Kirby 3 CMS
# 2020/04/17
# shoesforindustry.net
# Local OSX - No SSL/Certs
# v 0.0.3
# www.domain.test
server {
listen 80;
server_name www.domain.test;
access_log off;
# Redirect to the non-www host (declared below)
return 301 http://$host$request_uri;
}
# domain.test
server {
listen 80;
server_name domain.test;
root /PATH_TO_SITE/domain;
access_log off;
error_log /usr/local/etc/nginx/logs/error.log crit;
add_header X-Frame-Options SAMEORIGIN;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header "Cache-Control" "no-transform";
# Character Set
charset UTF-8;
# php
location ~\.php$ {
include /usr/local/etc/nginx/conf.d/php-fpm;
}
# block content
location ~ ^/content/(.*).(txt|md|mdown)$ {
rewrite ^/content/(.*).(txt|md|mdown)$ /error redirect;
}
# block all files in the site folder from being accessed directly
location ~ ^/site/(.*)$ {
rewrite ^/site/(.*)$ /error redirect;
}
# block all files in the kirby folder
location ~ ^/kirby/(.*)$ {
rewrite ^/kirby/(.*)$ /error redirect;
}
# site links
location / {
try_files $uri $uri/ /index.php;
}
# Error pages
error_page 404 /error;
error_page 403 /error;
}