Closed1
caddyをapt install
公式の通りインストール
sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl
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
設定ファイルを編集
sudo vi /etc/caddy/Caddyfile
:80を変数に置換
/etc/caddy/Caddyfile
{$DOMAIN} {
root * /usr/share/caddy
file_server
}
systemdファイルを編集
vi /usr/lib/systemd/system/caddy.service
Environment="DOMAIN=ドメイン名"でCaddyfileに変数を渡す
/usr/lib/systemd/system/caddy.service
[Unit]
Description=Caddy
Documentation=https://caddyserver.com/docs/
After=network.target network-online.target
Requires=network-online.target
[Service]
Type=notify
User=caddy
Group=caddy
Environment="DOMAIN=ドメイン名"
ExecStart=/usr/bin/caddy run --environ --config /etc/caddy/Caddyfile
ExecReload=/usr/bin/caddy reload --config /etc/caddy/Caddyfile --force
TimeoutStopSec=5s
LimitNOFILE=1048576
PrivateTmp=true
ProtectSystem=full
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
[Install]
WantedBy=multi-user.target
読み込み
systemctl daemon-reload
再起動
systemctl status caddy.service
このスクラップは3ヶ月前にクローズされました