Skip to content

Instantly share code, notes, and snippets.

@BilalBudhani
Last active January 13, 2020 14:03
Show Gist options
  • Save BilalBudhani/127786aa714809a6891f674d10213899 to your computer and use it in GitHub Desktop.
Save BilalBudhani/127786aa714809a6891f674d10213899 to your computer and use it in GitHub Desktop.
Caddy Systemd
# This service file requires the following:
#
# 1) Group named caddy:
# $ groupadd --system caddy
#
# 2) User named caddy, with a writeable home folder:
# $ useradd --system \
# --gid caddy \
# --create-home \
# --home-dir /var/lib/caddy \
# --shell /usr/sbin/nologin \
# --comment "Caddy web server" \
# caddy
#
# 3) Caddyfile at /etc/caddy/Caddyfile that is
# readable by the caddy user
#
[Unit]
Description=Caddy Web Server
Documentation=https://caddyserver.com/docs/
After=network.target
[Service]
Environment=CADDYPATH=/etc/ssl/caddy
User=caddy
Group=caddy
ExecStart=/usr/bin/caddy -log /var/log/caddy/caddy.log -agree=true -conf=/etc/caddy/Caddyfile -root=/var/tmp
ExecReload=/bin/kill -USR1 $MAINPID
TimeoutStopSec=5s
LimitNOFILE=1048576
LimitNPROC=512
PrivateTmp=true
ProtectSystem=full
AmbientCapabilities=CAP_NET_BIND_SERVICE
[Install]
WantedBy=multi-user.target
test.hostmatic.site {
gzip
root /var/www/
log /var/www/access.log
errors /var/www/errors.log
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment