146 字
1 分钟
Caddy 安装 + 常用配置
2022-01-28

安装caddy#

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 caddy

静态网页#

www.lolli.fun, xn--2o8ha.ml, xn--2o8haa.ml, lollipopkit.com, lolli.tech, blog.lolli.tech {
        root * /var/www/blog/public
        encode gzip
        file_server {
            hide .git
        }
}

反代#

HASHEDPASSWORD:由caddy hash-password [--plaintext <password>] [--algorithm <name>] [--salt <string>]生成

novel.lolli.tech {
        basicauth {
                USERNAME HASHEDPASSWORD
        }
        reverse_proxy {
                to jilin:1323 sh:1323 127.0.0.1:1323
                lb_policy random
        }
}

完全转发#

将所有请求完全转发到另一个服务器,并且保持原始请求的请求头(Host 和 IP 地址等)。

cdn.lolli.tech {
	reverse_proxy {
		to https://res.lolli.tech
		header_up Host {http.reverse_proxy.upstream.hostport}
		header_up X-Real-IP {http.request.remote.host}
		header_up X-Forwarded-For {http.request.remote.host}
		header_up X-Forwarded-Port {http.request.port}
		header_up X-Forwarded-Proto {http.request.scheme}
	}
}
Caddy 安装 + 常用配置
https://blog.lpkt.cn/posts/caddy-common/
作者
lollipopkit
发布于
2022-01-28
许可协议
CC BY-NC-SA 4.0