Webhook Based On Caddy¶
Introduction¶
This article introducing a method on building webhook service with CaddyServer.
1. Install CaddyServer¶
The easiest way to install caddy is using package manager.
-
On Debian/Ubuntu
sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' \ | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' \ | sudo tee /etc/apt/sources.list.d/caddy-stable.list sudo apt update sudo apt install caddy
-
On RHEL/CentOS/RockyLinux
2. Add Modules for Caddy¶
-
Add Packages Online
XXX is the package name, which always start withgithub.com/xxxxxx
.It's easy to find packages name from Download Page.
Examples:
install webhook module:
sudo caddy add-package github.com/WingLim/caddy-webhook
install exec module:
sudo caddy add-package github.com/mholt/caddy-events-exec
-
Add Packages Manually
Select and Download CaddyServer with modules from Download Page.
Replace executable
caddy
file with downloaded:
3. Modify CaddyServer's service file¶
Due to the configuration in default systemd file, the parameter ProtectSystem=full
, caddy lose the permission on writing /usr
, /boot
and /etc
.(Reference-2 for details).
-
Add ReadWrite permission to caddy web folder
/usr/share/caddy
Adding paramter to service file/usr/lib/systemd/system/caddy.service
under[service]
lable:ReadWritePaths=/usr/share/caddy
-
Reload systemd
sudo systemctl daemon-reload
4. Config Caddyfile¶
-
Webhook Module Configure introduction is available: caddy-webhook
-
Exec Module Configure introduction is available: caddy-exec
REF¶
[1]. https://caddyserver.com/docs/install
[2]. https://www.redhat.com/sysadmin/mastering-systemd
[3]. https://github.com/abiosoft/caddy-exec
[4]. https://github.com/WingLim/caddy-webhook