Caddy 一個(gè)強(qiáng)大仪缸、Api Server, 一鍵Https, 反向代理服務(wù)器
官網(wǎng): https://caddyserver.com/docs
ApiServer
- 創(chuàng)建一個(gè)文件
Caddyfile
- 運(yùn)行命令
caddy start
- 提示安裝證書 允許或拒絕 (一鍵Https)
- 打開瀏覽器
https:localhost
或http:localhost
- admin api
http://localhost:2019
localhost {
respond "Hello, world!"
}
file server
如下包括 encode zstd gzip
templates 可以解析html 模板內(nèi)的一些語(yǔ)法
file_server 開啟文件服務(wù)器
localhost {
encode zstd gzip
templates
file_server browse
}
image
玩點(diǎn)花的
- 開啟文件服務(wù)器到 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
}
image
如何給自己的服務(wù)器裝上 Https
- yum install yum-plugin-copr
- yum copr enable @caddy/caddy
- yum install caddy
- touch Caddyfile
- vim Caddyfile
baidu.com {
respond "Hello, world!"
}
- caddy start
就是如此的 Easy