简介

Caddy 是用GO写的网站服务软件,有很多时候,私人建站只需要一些简单的web服务,比较流行的方案LNMP或者LAMP相比之下就显得非常臃肿和过剩了。

非常之常用的一些功能:

  • 可以自动生成let’s encrypt的证书,并且能够自动更新证书。
  • File manager 插件,可以提供网盘功能,上存,下载,分享,视频在线播放,文件在线编辑,用户新增,权限等。
  • Webdav 插件,可以远程把文件夹映射。
  • Websocket 插件,和v2ray配合,翻墙再也不用怕ip被gfwed.

安装

访问 https://caddyserver.com/download, 选好平台,插件,等,在网页底下会出现安装方式的选择。

以下为树莓派ARMv7 安装 File manager 和 Webdav。

下载:
https://caddyserver.com/download/linux/arm7?plugins=http.authz,http.filemanager,http.webdav&license=personal&telemetry=off

命令行安装:
curl https://getcaddy.com | bash -s personal http.authz,http.filemanager,http.webdav

选择命令行安装,复制,粘贴运行即可。

配置

只要当前的文件夹下存在Caddyfile,那么运行命令之时,这个就是默认的配置文件。

配置模版:

https://simonchen.space/xxx {
log /xxx/file_access.log
tls /xxx/x.crt /xxx/x.key
timeouts none
gzip
filemanager / /xxx/xx/xxx {
database /xxx/xxx/xxx/filemanager.db
}
}
https://simonchen.space/xxxxx {
timeouts none
log /xxxx/filedav.log
tls /xxx/x.crt /xxx/x.key
gzip
basicauth / username password
webdav {
scope /share_folder/
}
}
simonchen.space:80 {
redir https://simonchen.space{uri}
}

修改后文件命名为 Caddyfile, 在当前文件夹执行caddy, 服务即启动。这时服务只存在当前,

我们可以用 nohup caddy & 放在后台,停用需要 ps -aux | grep caddy 找出进程,kill -9 把进程停掉。

参考

官方配置
Caddy - 方便够用的 HTTPS server 新手教程
清新脱俗的 Web 服务器 Caddy