• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

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

linux 搞代码 4年前 (2022-03-03) 23次浏览 已收录 0个评论
文章目录[隐藏]

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


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:Caddy-一个强大Api-Server-一键Https-反向代理服务器
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址