它本身是二進制檔案,沒有依賴,部署上是輕鬆的
Caddy支援Windows / Linux / macOS
Caddy優點
- HTTP/2
- 支持HTTP/3
- Automatic HTTPS
- Multi-core
- Websockets
- Markdown
- Reverse proxy
- Load balancing
- Static WEB
- IPv6
- Custom Log
- Micro Service
Caddy缺點
- 性能相較於Nginx / Apache還是略差
- 功能較少
- 社群不夠龐大
sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install -y caddy
下方就是預設的配置,非常清楚
80 port 的跟目錄是哪個資料夾
:80 {
# Set this path to your site's directory.
root * /usr/share/caddy
# Enable the static file server.
file_server
# Another common task is to set up a reverse proxy:
# reverse_proxy localhost:8080
# Or serve a PHP site through php-fpm:
# php_fastcgi localhost:9000
}
向下方這個配置來說,有人連到7777 port,會自動反向代理到9001port上,配置上相比Nginx來說是較為簡單
不過以商業的角度來說,Nginx還是比較強的,畢竟是用C撰寫出來相比Go性能還是絕對強悍:9001 { respond "I am CY" } :7777 { reverse_proxy :9001 }
Caddy比較適合用在個人網站,或是開發時可以拿來稍微用下