nixberg / caddy

Snap of the Caddy web server
4 stars 2 forks source link

Snap caddy cant find Caddyfile #3

Closed yodog closed 2 years ago

yodog commented 2 years ago

details here: https://caddy.community/t/snap-caddy-cant-find-caddyfile


caddy version v2.4.5 h1:P1mRs6V2cMcagSPn+NWpD+OEYUYLIf6ecOa48cFGeUg=

installed with snap install caddy --edge

on Raspberry Pi Linux pi 5.10.60-v7+ #1449 SMP Wed Aug 25 15:00:01 BST 2021 armv7l GNU/Linux

i created a file /tmp/Caddyfile but Caddy insists it does not exists and refuses to start :confused:

root@pi:/tmp# ls -lh /tmp/Caddyfile*
-rw-r--r-- 1 pi pi 122 Sep 29 12:00 /tmp/Caddyfile
root@pi:/tmp# cat /tmp/Caddyfile 
localhost:81 {
    respond "Hello, world!"
}
localhost:82 {
    respond "Goodbye, world!"
}
root@pi:/tmp# caddy adapt
adapt: input file required when there is no Caddyfile in current directory (use --config flag)
root@pi:/tmp# caddy adapt --config Caddyfile --validate
adapt: reading input file: open Caddyfile: no such file or directory
root@pi:/tmp# caddy adapt --config /tmp/Caddyfile 
adapt: reading input file: open /tmp/Caddyfile: no such file or directory
root@pi:/tmp# caddy start
start: opening listener for success confirmation: listen tcp 127.0.0.1:0: listen: operation not permitted
nixberg commented 2 years ago

Snaps are sandboxed and thus have no access to outside files. Also, by default, the snap starts an instance of caddy. So whenever you change the Caddyfile you should run:

curl localhost:2019/load --request POST --header 'Content-Type: text/caddyfile' --data-binary @<PATH_TO_CADDYFILE>

I’ve updated the README.