本文编写于 1598 天前,最后修改于 1382 天前,其中某些信息可能已经过时。
1、一键安装caddy
curl https://getcaddy.com | bash -s personal
wget --no-check-certificate -O /usr/bin/caddy https://cloud.shenbi.me/caddy/caddy_linux_amd64
2、创建 caddy配置文件存放目录和ssl证书存放目录编辑配置文件:
mkdir -p /etc/caddy && mkdir -p /etc/ssl/caddy
新建一个配置文件:新建一个配置文件:
vim /etc/caddy/Caddyfile
jp.ytber.cn {
log stdout
root /var/www/jp.ytber.cn
tls [email protected]
proxy /phpmyadmin localhost:10086 {
websocket
header_upstream -Origin
}
}
通过IP即80端口访问目录
:80 {
log stdout
root /var/www/kcdtw.btcloud.bid
tls [email protected]
proxy /btfly localhost:10086 {
websocket
header_upstream -Origin
}
}
创建Systemd服务文件:
/etc/systemd/system/caddy.service
填入
[Unit]
Description=Caddy HTTP/2 web server
Documentation=https://caddyserver.com/docs
After=network-online.target
Wants=network-online.target systemd-networkd-wait-online.service
[Service]
Restart=on-abnormal
User=root
Group=root
Environment=CADDYPATH=/etc/ssl/caddy
ExecStart=/usr/local/bin/caddy -log stdout -agree=true -conf=/etc/caddy/Caddyfile
ExecReload=/bin/kill -USR1 \$MAINPID
KillMode=mixed
KillSignal=SIGQUIT
TimeoutStopSec=5s
[Install]
WantedBy=multi-user.target
启动服务
systemctl start caddy
systemctl enable caddy
重启服务
systemctl restart caddy