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
    6.

    baidu.com { respond "Hello, world!"}
  6. caddy start

就是如此的 Easy

更多内容浏览官网文档

https://caddyserver.com/docs