Caddy 一個強大、Api Server, 一鍵Https, 反向代理服務器


Caddy 一個強大、Api Server, 一鍵Https, 反向代理服務器# 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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM