caddy
macOS 下可以 brew install caddy, 当前 v2 体验不错
old nginx.conf
1 | server { |
Caddyfile
1 | # |
caddy 使用体验
DX
VSCode Extension https://marketplace.visualstudio.com/items?itemName=matthewpi.caddyfile-support
caddy & nginx
proxy_pass / reverse_proxy
nginx proxy_pass
proxy_pass 比较 trick, proxy_pass http://127.0.0.1:1235; 和 proxy_pass http://127.0.0.1:1235/; 结果是不一样的, ending slash 会 trim prefix
caddy reverse_proxy
caddy 可以使用 handle_path 去 trim prefix, 更直观
reload config
- nginx: edit .conf file,
nginx -s reload - caddy: 可以使用
caddy run --watch, watch Caddyfile 的变化自动 reload
brew services
在 macOS 中均可以用 brew services 来管理, 配置文件
/usr/local/etc/nginx.conf/usr/local/etc/Caddyfile
handle / handle_path / route
route内部不会对 directives 重新排序handle互斥, 更好的隔离, 可以嵌套