dulli / caddy-wol

Caddy plugin that sends wake-on-lan magic packets to remote hosts to wake up e.g. reverse proxy targets.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failing to launch caddy with only caddy-wol plugin on caddy 2.7.5 in go 1.21.1 on debian 11

michael94ellis opened this issue · comments

Hey, thanks for making this plugin! I happen to be experiencing an issue while trying to use caddy with caddy-wol as a debian 11 system service unit.

For reference I posted this first on the caddy forum and was recommended to come to you. I am a novice with Go and am not yet able to make out how to handle or investigate this error.
https://caddy.community/t/caddy-service-fails-when-not-logged-in/21532/3

Debian 11
Go 1.21.1
Caddy 2.7.5

When I run this as a system service while logged in caddy runs as expected, but the problem is that when I reboot it fails to run before I log in.

The helpful user that sent me here made this snippet from my logs when they directed me to reach out to you

ct 30 18:49:32 caddy caddy[473]: panic: runtime error: invalid memory address or nil pointer dereference
Oct 30 18:49:32 caddy caddy[473]: [signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x12a2190]
Oct 30 18:49:32 caddy caddy[473]: goroutine 1 [running]:
Oct 30 18:49:32 caddy caddy[473]: github.com/dulli/caddy-wol.(*Middleware).Cleanup(0x3d40a40)
Oct 30 18:49:32 caddy caddy[473]:         github.com/dulli/caddy-wol@v1.0.0/middleware.go:113 +0x1c
Oct 30 18:49:32 caddy caddy[473]: github.com/caddyserver/caddy/v2.Context.LoadModuleByID({{0x1a411a4, 0x3c7e918}, 0x3afd0c0, 0x3b0a090, {0x0, 0x0, 0x0}, {0x3bbb820, 0x4, 0x4}}, ...)

service unit file

[Unit]
Description=Caddy HTTP/2 web server
Documentation=https://caddyserver.com/docs/
After=network.target network-online.target

[Service]
User=root
Group=root
ExecStart=/usr/local/bin/caddy run --environ --config "/etc/caddy/Caddyfile"
ExecReload=/usr/local/bin/caddy reload --config /etc/caddy/Caddyfile --force
TimeoutStopSec=5s
LimitNOFILE=1048576
LimitNPROC=512
ProtectSystem=true
PrivateTmp=true
CapabilityBoundingSet=CAP_NET_BIND_SERVICE
AmbientCapabilities=CAP_NET_BIND_SERVICE

[Install]
WantedBy=multi-user.target

Caddyfile[redacted]

{
	email 'myDomainRegisteredEmail@gmail.com'
	order wake_on_lan before respond
}

https://sub.mydomain.com {
	tls myDomainRegisteredEmail@gmail.com
	reverse_proxy 192.168.1.254:8096
	handle_errors {
		@502 expression {err.status_code} == 502
		handle @502 {
			wake_on_lan 11-22-33-44-55-66 192.168.1.254:9
			reverse_proxy 192.168.1.254:8096 {
				lb_try_duration 30s
			}
		}
	}
}

There are also 3 more with the same config for different subdomains, https only

I just tried rebuilding caddy pointing to the main branch for this plugin and got the same error

I'm going to try to keep looking, but i have been looking for help with this error for a couple days now. I think maybe knowing it is not caddy that is failing might help me find more results though.

Let me know if I can provide any other information, thanks!

Here is the full log out from last reboot, it does work when the I have logged in, but not before I log in, however I wasnt able to test the wake on lan and get a successful boot yet which may or may not be related to my issue.

-- Boot 57a322c6160e4163a6984dbc947dd824 --
Oct 30 18:49:29 caddy systemd[1]: Started Caddy HTTP/2 web server.
Oct 30 18:49:32 caddy caddy[473]: caddy.HomeDir=/root
Oct 30 18:49:32 caddy caddy[473]: caddy.AppDataDir=/root/.local/share/caddy
Oct 30 18:49:32 caddy caddy[473]: caddy.AppConfigDir=/root/.config/caddy
Oct 30 18:49:32 caddy caddy[473]: caddy.ConfigAutosavePath=/root/.config/caddy/autosave.json
Oct 30 18:49:32 caddy caddy[473]: caddy.Version=v2.7.5 h1:HoysvZkLcN2xJExEepaFHK92Qgs7xAiCFydN5x5Hs6Q=
Oct 30 18:49:32 caddy caddy[473]: runtime.GOOS=linux
Oct 30 18:49:32 caddy caddy[473]: runtime.GOARCH=arm
Oct 30 18:49:32 caddy caddy[473]: runtime.Compiler=gc
Oct 30 18:49:32 caddy caddy[473]: runtime.NumCPU=4
Oct 30 18:49:32 caddy caddy[473]: runtime.GOMAXPROCS=4
Oct 30 18:49:32 caddy caddy[473]: runtime.Version=go1.21.1
Oct 30 18:49:32 caddy caddy[473]: os.Getwd=/
Oct 30 18:49:32 caddy caddy[473]: LANG=en_GB.UTF-8
Oct 30 18:49:32 caddy caddy[473]: PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Oct 30 18:49:32 caddy caddy[473]: HOME=/root
Oct 30 18:49:32 caddy caddy[473]: LOGNAME=root
Oct 30 18:49:32 caddy caddy[473]: USER=root
Oct 30 18:49:32 caddy caddy[473]: SHELL=/bin/sh
Oct 30 18:49:32 caddy caddy[473]: INVOCATION_ID=fc18c947fa6c4165bdbe619a8495edce
Oct 30 18:49:32 caddy caddy[473]: JOURNAL_STREAM=8:14578
Oct 30 18:49:32 caddy caddy[473]: {"level":"info","ts":1698706172.033477,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":""}
Oct 30 18:49:32 caddy caddy[473]: {"level":"info","ts":1698706172.099299,"logger":"admin","msg":"admin endpoint started","address":"localhost:2019","enforce_origin":false,"origins":["//127.0.0.1:2019","//localhost:2019","//[::1]:2019"]}
Oct 30 18:49:32 caddy caddy[473]: {"level":"info","ts":1698706172.1029108,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0x3b184e0"}
Oct 30 18:49:32 caddy caddy[473]: {"level":"info","ts":1698706172.1040614,"logger":"http.auto_https","msg":"server is listening only on the HTTPS port but has no TLS connection policies; adding one to enable TLS","server_name":"srv0","https_port":443}
Oct 30 18:49:32 caddy caddy[473]: {"level":"info","ts":1698706172.1043956,"logger":"http.auto_https","msg":"enabling automatic HTTP->HTTPS redirects","server_name":"srv0"}
Oct 30 18:49:32 caddy caddy[473]: panic: runtime error: invalid memory address or nil pointer dereference
Oct 30 18:49:32 caddy caddy[473]: [signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x12a2190]
Oct 30 18:49:32 caddy caddy[473]: goroutine 1 [running]:
Oct 30 18:49:32 caddy caddy[473]: github.com/dulli/caddy-wol.(*Middleware).Cleanup(0x3d40a40)
Oct 30 18:49:32 caddy caddy[473]:         github.com/dulli/caddy-wol@v1.0.0/middleware.go:113 +0x1c
Oct 30 18:49:32 caddy caddy[473]: github.com/caddyserver/caddy/v2.Context.LoadModuleByID({{0x1a411a4, 0x3c7e918}, 0x3afd0c0, 0x3b0a090, {0x0, 0x0, 0x0}, {0x3bbb820, 0x4, 0x4}}, ...)
Oct 30 18:49:32 caddy caddy[473]:         github.com/caddyserver/caddy/v2@v2.7.5/context.go:352 +0x790
Oct 30 18:49:32 caddy caddy[473]: github.com/caddyserver/caddy/v2.Context.loadModuleInline({{0x1a411a4, 0x3c7e918}, 0x3afd0c0, 0x3b0a090, {0x0, 0x0, 0x0}, {0x3bbb820, 0x3, 0x4}}, ...)
Oct 30 18:49:32 caddy caddy[473]:         github.com/caddyserver/caddy/v2@v2.7.5/context.go:397 +0xe8
Oct 30 18:49:32 caddy caddy[473]: github.com/caddyserver/caddy/v2.Context.LoadModule({{0x1a411a4, 0x3c7e918}, 0x3afd0c0, 0x3b0a090, {0x0, 0x0, 0x0}, {0x3bbb820, 0x3, 0x4}}, ...)
Oct 30 18:49:32 caddy caddy[473]:         github.com/caddyserver/caddy/v2@v2.7.5/context.go:176 +0x734
Oct 30 18:49:32 caddy caddy[473]: github.com/caddyserver/caddy/v2/modules/caddyhttp.(*Route).ProvisionHandlers(0x3b05540, {{0x1a411a4, 0x3c7e918}, 0x3afd0c0, 0x3b0a090, {0x0, 0x0, 0x0}, {0x3bbb820, 0x3, ...}}, ...)
Oct 30 18:49:32 caddy caddy[473]:         github.com/caddyserver/caddy/v2@v2.7.5/modules/caddyhttp/routes.go:154 +0x40
Oct 30 18:49:32 caddy caddy[473]: github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.ProvisionHandlers({0x3b05540, 0x1, 0x1}, {{0x1a411a4, 0x3c7e918}, 0x3afd0c0, 0x3b0a090, {0x0, 0x0, 0x0}, ...}, ...)
Oct 30 18:49:32 caddy caddy[473]:         github.com/caddyserver/caddy/v2@v2.7.5/modules/caddyhttp/routes.go:209 +0x58
Oct 30 18:49:32 caddy caddy[473]: github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Provision({0x3b05540, 0x1, 0x1}, {{0x1a411a4, 0x3c7e918}, 0x3afd0c0, 0x3b0a090, {0x0, 0x0, 0x0}, ...})
Oct 30 18:49:32 caddy caddy[473]:         github.com/caddyserver/caddy/v2@v2.7.5/modules/caddyhttp/routes.go:186 +0x88
Oct 30 18:49:32 caddy caddy[473]: github.com/caddyserver/caddy/v2/modules/caddyhttp.(*Subroute).Provision(0x3b1b550, {{0x1a411a4, 0x3c7e918}, 0x3afd0c0, 0x3b0a090, {0x0, 0x0, 0x0}, {0x3bbb820, 0x3, ...}})
Oct 30 18:49:32 caddy caddy[473]:         github.com/caddyserver/caddy/v2@v2.7.5/modules/caddyhttp/subroute.go:58 +0x44
Oct 30 18:49:32 caddy caddy[473]: github.com/caddyserver/caddy/v2.Context.LoadModuleByID({{0x1a411a4, 0x3c7e918}, 0x3afd0c0, 0x3b0a090, {0x0, 0x0, 0x0}, {0x3bbb820, 0x3, 0x4}}, ...)
Oct 30 18:49:32 caddy caddy[473]:         github.com/caddyserver/caddy/v2@v2.7.5/context.go:347 +0x428
Oct 30 18:49:32 caddy caddy[473]: github.com/caddyserver/caddy/v2.Context.loadModuleInline({{0x1a411a4, 0x3c7e918}, 0x3afd0c0, 0x3b0a090, {0x0, 0x0, 0x0}, {0x3a8f7c0, 0x2, 0x2}}, ...)
Oct 30 18:49:32 caddy caddy[473]:         github.com/caddyserver/caddy/v2@v2.7.5/context.go:397 +0xe8
Oct 30 18:49:32 caddy caddy[473]: github.com/caddyserver/caddy/v2.Context.LoadModule({{0x1a411a4, 0x3c7e918}, 0x3afd0c0, 0x3b0a090, {0x0, 0x0, 0x0}, {0x3a8f7c0, 0x2, 0x2}}, ...)
Oct 30 18:49:32 caddy caddy[473]:         github.com/caddyserver/caddy/v2@v2.7.5/context.go:176 +0x734
Oct 30 18:49:32 caddy caddy[473]: github.com/caddyserver/caddy/v2/modules/caddyhttp.(*Route).ProvisionHandlers(0x3c88640, {{0x1a411a4, 0x3c7e918}, 0x3afd0c0, 0x3b0a090, {0x0, 0x0, 0x0}, {0x3a8f7c0, 0x2, ...}}, ...)
Oct 30 18:49:32 caddy caddy[473]:         github.com/caddyserver/caddy/v2@v2.7.5/modules/caddyhttp/routes.go:154 +0x40
Oct 30 18:49:32 caddy caddy[473]: github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.ProvisionHandlers({0x3c88640, 0x1, 0x1}, {{0x1a411a4, 0x3c7e918}, 0x3afd0c0, 0x3b0a090, {0x0, 0x0, 0x0}, ...}, ...)
Oct 30 18:49:32 caddy caddy[473]:         github.com/caddyserver/caddy/v2@v2.7.5/modules/caddyhttp/routes.go:209 +0x58
Oct 30 18:49:32 caddy caddy[473]: github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Provision({0x3c88640, 0x1, 0x1}, {{0x1a411a4, 0x3c7e918}, 0x3afd0c0, 0x3b0a090, {0x0, 0x0, 0x0}, ...})
Oct 30 18:49:32 caddy caddy[473]:         github.com/caddyserver/caddy/v2@v2.7.5/modules/caddyhttp/routes.go:186 +0x88
Oct 30 18:49:32 caddy caddy[473]: github.com/caddyserver/caddy/v2/modules/caddyhttp.(*Subroute).Provision(0x3a8f760, {{0x1a411a4, 0x3c7e918}, 0x3afd0c0, 0x3b0a090, {0x0, 0x0, 0x0}, {0x3a8f7c0, 0x2, ...}})
Oct 30 18:49:32 caddy caddy[473]:         github.com/caddyserver/caddy/v2@v2.7.5/modules/caddyhttp/subroute.go:58 +0x44
Oct 30 18:49:32 caddy caddy[473]: github.com/caddyserver/caddy/v2.Context.LoadModuleByID({{0x1a411a4, 0x3c7e918}, 0x3afd0c0, 0x3b0a090, {0x0, 0x0, 0x0}, {0x3a8f7c0, 0x2, 0x2}}, ...)
Oct 30 18:49:32 caddy caddy[473]:         github.com/caddyserver/caddy/v2@v2.7.5/context.go:347 +0x428
Oct 30 18:49:32 caddy caddy[473]: github.com/caddyserver/caddy/v2.Context.loadModuleInline({{0x1a411a4, 0x3c7e918}, 0x3afd0c0, 0x3b0a090, {0x0, 0x0, 0x0}, {0x3c722c8, 0x1, 0x1}}, ...)
Oct 30 18:49:32 caddy caddy[473]:         github.com/caddyserver/caddy/v2@v2.7.5/context.go:397 +0xe8
Oct 30 18:49:32 caddy caddy[473]: github.com/caddyserver/caddy/v2.Context.LoadModule({{0x1a411a4, 0x3c7e918}, 0x3afd0c0, 0x3b0a090, {0x0, 0x0, 0x0}, {0x3c722c8, 0x1, 0x1}}, ...)
Oct 30 18:49:32 caddy caddy[473]:         github.com/caddyserver/caddy/v2@v2.7.5/context.go:176 +0x734
Oct 30 18:49:32 caddy caddy[473]: github.com/caddyserver/caddy/v2/modules/caddyhttp.(*Route).ProvisionHandlers(0x3c68090, {{0x1a411a4, 0x3c7e918}, 0x3afd0c0, 0x3b0a090, {0x0, 0x0, 0x0}, {0x3c722c8, 0x1, ...}}, ...)
Oct 30 18:49:32 caddy caddy[473]:         github.com/caddyserver/caddy/v2@v2.7.5/modules/caddyhttp/routes.go:154 +0x40
Oct 30 18:49:32 caddy caddy[473]: github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.ProvisionHandlers({0x3c68090, 0x2, 0x2}, {{0x1a411a4, 0x3c7e918}, 0x3afd0c0, 0x3b0a090, {0x0, 0x0, 0x0}, ...}, ...)
Oct 30 18:49:32 caddy caddy[473]:         github.com/caddyserver/caddy/v2@v2.7.5/modules/caddyhttp/routes.go:209 +0x58
Oct 30 18:49:32 caddy caddy[473]: github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Provision({0x3c68090, 0x2, 0x2}, {{0x1a411a4, 0x3c7e918}, 0x3afd0c0, 0x3b0a090, {0x0, 0x0, 0x0}, ...})
Oct 30 18:49:32 caddy caddy[473]:         github.com/caddyserver/caddy/v2@v2.7.5/modules/caddyhttp/routes.go:186 +0x88
Oct 30 18:49:32 caddy caddy[473]: github.com/caddyserver/caddy/v2/modules/caddyhttp.(*App).Provision(0x3b18480, {{0x1a411a4, 0x3c7e918}, 0x3afd0c0, 0x3b0a090, {0x0, 0x0, 0x0}, {0x3c722c8, 0x1, ...}})
Oct 30 18:49:32 caddy caddy[473]:         github.com/caddyserver/caddy/v2@v2.7.5/modules/caddyhttp/app.go:297 +0xc74
Oct 30 18:49:32 caddy caddy[473]: github.com/caddyserver/caddy/v2.Context.LoadModuleByID({{0x1a411c4, 0x3b0a0f0}, 0x3afd0c0, 0x3b0a090, {0x0, 0x0, 0x0}, {0x3c722c8, 0x1, 0x1}}, ...)
Oct 30 18:49:32 caddy caddy[473]:         github.com/caddyserver/caddy/v2@v2.7.5/context.go:347 +0x428
Oct 30 18:49:32 caddy caddy[473]: github.com/caddyserver/caddy/v2.Context.App({{0x1a411c4, 0x3b0a0f0}, 0x3afd0c0, 0x3b0a090, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}}, ...)
Oct 30 18:49:32 caddy caddy[473]:         github.com/caddyserver/caddy/v2@v2.7.5/context.go:423 +0xf0
Oct 30 18:49:32 caddy caddy[473]: github.com/caddyserver/caddy/v2.run.func3(...)
Oct 30 18:49:32 caddy caddy[473]:         github.com/caddyserver/caddy/v2@v2.7.5/caddy.go:480
Oct 30 18:49:32 caddy caddy[473]: github.com/caddyserver/caddy/v2.run(0x3b0a090, 0x1)
Oct 30 18:49:32 caddy caddy[473]:         github.com/caddyserver/caddy/v2@v2.7.5/caddy.go:485 +0x3b0
Oct 30 18:49:32 caddy caddy[473]: github.com/caddyserver/caddy/v2.unsyncedDecodeAndRun({0x3b12800, 0x7a0, 0x800}, 0x1)
Oct 30 18:49:32 caddy caddy[473]:         github.com/caddyserver/caddy/v2@v2.7.5/caddy.go:338 +0x16c
Oct 30 18:49:32 caddy caddy[473]: github.com/caddyserver/caddy/v2.changeConfig({0x157ce9c, 0x4}, {0x1583da1, 0x7}, {0x3b12000, 0x7a0, 0x800}, {0x0, 0x0}, 0x1)
Oct 30 18:49:32 caddy caddy[473]:         github.com/caddyserver/caddy/v2@v2.7.5/caddy.go:229 +0x7b0
Oct 30 18:49:32 caddy caddy[473]: github.com/caddyserver/caddy/v2.Load({0x3b12000, 0x7a0, 0x800}, 0x1)
Oct 30 18:49:32 caddy caddy[473]:         github.com/caddyserver/caddy/v2@v2.7.5/caddy.go:128 +0x1c0
Oct 30 18:49:32 caddy caddy[473]: github.com/caddyserver/caddy/v2/cmd.cmdRun({0x396d680})
Oct 30 18:49:32 caddy caddy[473]:         github.com/caddyserver/caddy/v2@v2.7.5/cmd/commandfuncs.go:231 +0x6d0
Oct 30 18:49:32 caddy caddy[473]: github.com/caddyserver/caddy/v2/cmd.init.1.func2.WrapCommandFuncForCobra.func1(0x3aff800, {0x3be3c38, 0x0, 0x3})
Oct 30 18:49:32 caddy caddy[473]:         github.com/caddyserver/caddy/v2@v2.7.5/cmd/cobra.go:137 +0x38
Oct 30 18:49:32 caddy caddy[473]: github.com/spf13/cobra.(*Command).execute(0x3aff800, {0x3be3c20, 0x3, 0x3})
Oct 30 18:49:32 caddy caddy[473]:         github.com/spf13/cobra@v1.7.0/command.go:940 +0x7a8
Oct 30 18:49:32 caddy caddy[473]: github.com/spf13/cobra.(*Command).ExecuteC(0x256c400)
Oct 30 18:49:32 caddy caddy[473]:         github.com/spf13/cobra@v1.7.0/command.go:1068 +0x410
Oct 30 18:49:32 caddy caddy[473]: github.com/spf13/cobra.(*Command).Execute(...)
Oct 30 18:49:32 caddy caddy[473]:         github.com/spf13/cobra@v1.7.0/command.go:992
Oct 30 18:49:32 caddy caddy[473]: github.com/caddyserver/caddy/v2/cmd.Main()
Oct 30 18:49:32 caddy caddy[473]:         github.com/caddyserver/caddy/v2@v2.7.5/cmd/main.go:66 +0x7c
Oct 30 18:49:32 caddy caddy[473]: main.main()
Oct 30 18:49:32 caddy caddy[473]:         caddy/main.go:12 +0x14
Oct 30 18:49:32 caddy systemd[1]: caddy.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
Oct 30 18:49:32 caddy systemd[1]: caddy.service: Failed with result 'exit-code'.
Oct 30 18:53:48 caddy systemd[1]: Started Caddy HTTP/2 web server.
Oct 30 18:53:48 caddy caddy[624]: caddy.HomeDir=/root
Oct 30 18:53:48 caddy caddy[624]: caddy.AppDataDir=/root/.local/share/caddy
Oct 30 18:53:48 caddy caddy[624]: caddy.AppConfigDir=/root/.config/caddy
Oct 30 18:53:48 caddy caddy[624]: caddy.ConfigAutosavePath=/root/.config/caddy/autosave.json
Oct 30 18:53:48 caddy caddy[624]: caddy.Version=v2.7.5 h1:HoysvZkLcN2xJExEepaFHK92Qgs7xAiCFydN5x5Hs6Q=
Oct 30 18:53:48 caddy caddy[624]: runtime.GOOS=linux
Oct 30 18:53:48 caddy caddy[624]: runtime.GOARCH=arm
Oct 30 18:53:48 caddy caddy[624]: runtime.Compiler=gc
Oct 30 18:53:48 caddy caddy[624]: runtime.NumCPU=4
Oct 30 18:53:48 caddy caddy[624]: runtime.GOMAXPROCS=4
Oct 30 18:53:48 caddy caddy[624]: runtime.Version=go1.21.1
Oct 30 18:53:48 caddy caddy[624]: os.Getwd=/
Oct 30 18:53:48 caddy caddy[624]: LANG=en_GB.UTF-8
Oct 30 18:53:48 caddy caddy[624]: PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Oct 30 18:53:48 caddy caddy[624]: HOME=/root
Oct 30 18:53:48 caddy caddy[624]: LOGNAME=root
Oct 30 18:53:48 caddy caddy[624]: USER=root
Oct 30 18:53:48 caddy caddy[624]: SHELL=/bin/sh
Oct 30 18:53:48 caddy caddy[624]: INVOCATION_ID=403e7fe47881490c9a86c79ce80c47b0
Oct 30 18:53:48 caddy caddy[624]: JOURNAL_STREAM=8:11693
Oct 30 18:53:48 caddy caddy[624]: {"level":"info","ts":1698706428.6234171,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":""}
Oct 30 18:53:48 caddy caddy[624]: {"level":"info","ts":1698706428.6761577,"logger":"admin","msg":"admin endpoint started","address":"localhost:2019","enforce_origin":false,"origins":["//localhost:2019","//[::1]:2019","//127.0.0.1:2019"]}
Oct 30 18:53:48 caddy caddy[624]: {"level":"info","ts":1698706428.6785362,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0x33fb4a0"}
Oct 30 18:53:48 caddy caddy[624]: {"level":"info","ts":1698706428.6796942,"logger":"http.auto_https","msg":"server is listening only on the HTTPS port but has no TLS connection policies; adding one to enable TLS","server_name":"srv0","https_port":443}
Oct 30 18:53:48 caddy caddy[624]: {"level":"info","ts":1698706428.6799161,"logger":"http.auto_https","msg":"enabling automatic HTTP->HTTPS redirects","server_name":"srv0"}
Oct 30 18:53:48 caddy caddy[624]: {"level":"info","ts":1698706428.768512,"logger":"http","msg":"enabling HTTP/3 listener","addr":":443"}
Oct 30 18:53:48 caddy caddy[624]: {"level":"info","ts":1698706428.7740285,"msg":"failed to sufficiently increase receive buffer size (was: 176 kiB, wanted: 2048 kiB, got: 352 kiB). See https://github.com/quic-go/quic-go/wiki/UDP-Buffer-Sizes for details."}
Oct 30 18:53:48 caddy caddy[624]: {"level":"info","ts":1698706428.7759168,"logger":"http.log","msg":"server running","name":"srv0","protocols":["h1","h2","h3"]}
Oct 30 18:53:48 caddy caddy[624]: {"level":"info","ts":1698706428.776901,"logger":"http.log","msg":"server running","name":"remaining_auto_https_redirects","protocols":["h1","h2","h3"]}
Oct 30 18:53:48 caddy caddy[624]: {"level":"info","ts":1698706428.7772384,"logger":"http","msg":"enabling automatic TLS certificate management","domains":["a1.a.in","a2.a.in","a3.a.in","a4.a.in"]}
Oct 30 18:53:48 caddy caddy[624]: {"level":"info","ts":1698706428.927163,"logger":"tls","msg":"cleaning storage unit","description":"FileStorage:/root/.local/share/caddy"}
Oct 30 18:53:48 caddy caddy[624]: {"level":"info","ts":1698706428.9365911,"msg":"autosaved config (load with --resume flag)","file":"/root/.config/caddy/autosave.json"}
Oct 30 18:53:48 caddy caddy[624]: {"level":"info","ts":1698706428.9368,"msg":"serving initial configuration"}
Oct 30 18:53:48 caddy caddy[624]: {"level":"info","ts":1698706428.93848,"logger":"tls","msg":"finished cleaning storage units"}

I have no idea but would this potentially be solved by adding a nil check?

from my lack knowledge and research I found that Caddy is actually calling cleanup and then this causes a failure, but the broadcast socket is udp so I dont see why it wouldn't be open unless maybe it's my firewall. I tried adding outgoing udp traffic in ufw for port 9 but am still seeing the same error on reboot

I also tried disabling my firewall and that did not fix it either. It still runs after login

https://unix.stackexchange.com/questions/573980/cant-open-socket-im-systemd-service

GPT saved the day, after probing it about my error from the first log snippet provided it told me about the middleware Cleanup() func. From there I realized it was failing to open a udp socket before login, but worked after login. So I kept asking questions and eventually it provided me with an answer + source(see above link).

My unit file needed to be like this.
After=network.target sockets.target network-online.target multi-user.target

Thanks for your update! I was just about to look into this, so great to hear that it now works for you 😄