Caddy 一个强大、Api Server, 一键Https, 反向代理服务器# Caddy 一个强大、Api Server, 一键Https, 反向代理服务器 官网: https://caddyse

Caddy 一个强大、Api Server, 一键Https, 反向代理服务器

官网: https://caddyserver.com/docs

ApiServer

  1. 创建一个文件 Caddyfile
  2. 运行命令 caddy start
  3. 提示安装证书 允许或拒绝 (一键Https)
  4. 打开浏览器 https:localhosthttp:localhost
  5. 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
}

玩点花的

  1. 开启文件服务器到 80端口
  2. 8080 端口访问 hello 返回字符串
  3. 8081 反向代理 8080 端口
  4. 8082 只开启 http
  5. 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

  1. yum install yum-plugin-copr
  2. yum copr enable @caddy/caddy
  3. yum install caddy
  4. touch Caddyfile
  5. vim Caddyfile
baidu.com {
    respond "Hello, world!"
}
  1. caddy start

就是如此的 Easy

更多内容阅读官方文档

https://caddyserver.com/docs

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Smallstone丶

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值