轻量化 Web 服务器 Caddy
Caddy is a powerful, enterprise-ready, open source web server with automatic HTTPS written in Go.
3.1. 安装 Caddy
3.1.1. CentOS/Rocky Linux/AlmiLinux
[root@netkiller ~]# dnf install 'dnf-command(copr)' [root@netkiller ~]# dnf copr enable @caddy/caddy [root@netkiller ~]# dnf install caddy [root@netkiller ~]# systemctl enable caddy [root@netkiller ~]# systemctl start caddy [root@netkiller ~]# cp /etc/caddy/Caddyfile{,.original}
3.2. 命令行
3.2.1. 启动 Caddy
前台运行
caddy run --config /etc/caddy/Caddyfile --adapter caddyfile
3.2.1.1. 开启 QUIC
caddy run --config /etc/caddy/Caddyfile --adapter caddyfile --quic
3.2.2. 文件服务器
将当前目录作为文件服务器的根目录
$ caddy file-server
指定端口
$ caddy file-server --listen :8080
不打开 index.html,显示文件目录
$ caddy file-server --browse
指定文件服务器根目录
$ caddy file-server --root ~/public_html
3.3. /etc/caddy/Caddyfile
The Caddyfile — Caddy Documentation
3.3.1. 监听地址
localhost example.com :443 http://example.com localhost:8080 127.0.0.1 [::1]:2015 example.com/foo/* *.example.com http://
localhost:8080, example.