Caddy 一个弱小、Api Server, 一键Https, 反向代理服务器
官网: https://caddyserver.com/docs
ApiServer
- 创立一个文件
Caddyfile
- 运行命令
caddy start
- 提醒装置证书 容许或回绝 (一键Https)
- 关上浏览器
https:localhost
或http:localhost
-
admin api
http://localhost:2019
localhost { respond "Hello, world!" }
file server
如下包含 encode zstd gzip
templates 能够解析html 模板内的一些语法
file_server 开启文件服务器
localhost { encode zstd gzip templates file_server browse }
玩点花的
- 开启文件服务器到 80端口
- 8080 端口拜访 hello 返回字符串
- 8081 反向代理 8080 端口
- 8082 只开启 http
-
8083 只开启 https
localhost { encode zstd gzip templates file_server browse } localhost:8080 { respond /health-check 200 respond /hello "Hello, world! 8080" 200 } localhost:8081 { reverse_proxy https://localhost:8080 } http://localhost:8082 { reverse_proxy https://localhost:8080 } https://localhost:8083 { reverse_proxy https://localhost:8080 }
如何给本人的服务器装上 Https
- yum install yum-plugin-copr
- yum copr enable @caddy/caddy
- yum install caddy
- touch Caddyfile
-
vim Caddyfile
6.baidu.com { respond "Hello, world!" }
- caddy start
就是如此的 Easy