Caddy
出自H.-H.'s Wiki
更多操作
安裝
# Install from Official Repository
$ apt install -y debian-keyring debian-archive-keyring apt-transport-https curl
$ curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
$ curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | tee /etc/apt/sources.list.d/caddy-stable.list
$ chmod o+r /usr/share/keyrings/caddy-stable-archive-keyring.gpg
$ chmod o+r /etc/apt/sources.list.d/caddy-stable.list
$ apt update
$ apt install caddy
# Replace with compiled version
$ xcaddy build --with [...]
$ systemctl stop caddy
$ cp /usr/bin/caddy /usr/bin/caddy.bak
$ cp ~/caddy /usr/bin/caddy
$ chmod 755 /usr/bin/caddy
$ setcap cap_net_bind_service=+ep /usr/bin/caddy
$ apt-mark hold caddy使用 Caddy 搭配 GeoIP 限制地區
demo.example.com {
@taiwan {
maxmind_geolocation {
db_path "/etc/caddy/GeoLite2-Country.mmdb"
allow_countries TW
}
}
handle @taiwan {
reverse_proxy https://demo.example.com {
header_up Host demo.example.com
header_up X-Real-IP {remote_host}
}
}
handle {
respond "Access Denied" 403
}
}