jhtone
jhtone
Published on 2024-12-04 / 50 Visits
1
0

搭建哪吒V1+CF CDN,适合纯V4或V6

cloudflare配置

  1. 进入域名里的DNS-记录,添加记录,设置子域名前缀,ipv4添加A记录,ipv6添加AAAA记录,开启小黄云

2.进入SSL/TLS-概述,将加密模式改成完全(严格)

3.进入SSL/TLS-源服务器,以域名example.com举例,创建一个*.example.com的证书,将源证书的代码和密钥的代码分别保存好

4.进入网络,开启WebsocketsgRPC

安装哪吒面板

curl -L https://gitlab.com/jinhuaitao66/nezha/-/raw/main/nezha.sh -o nezha.sh && chmod +x nezha.sh && sudo ./nezha.sh

安装Caddy

  1. 执行安装脚本

sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl
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

2.创建并保存证书文件,此处的example可以不更改,以下两行代码分别执行,然后将保存的代码粘贴进去

nano /etc/caddy/example.pem    #公钥
nano /etc/caddy/example.key    #私钥

3.配置Caddyfile,执行以下代码打开配置文件

nano /etc/caddy/Caddyfile
  1. 清空已有内容,并粘贴如下代码,其中第一行的nezha.example.com需要替换成实际解析的子域名,证书路径如果第2步保存的文件名没改,这里也不用改

nezha.example.com {
    reverse_proxy /proto.NezhaService/* h2c://127.0.0.1:8008
    tls /etc/caddy/example.pem /etc/caddy/example.key
    reverse_proxy /* 127.0.0.1:8008
}
  1. 启用并启动Caddy

systemctl enable caddy
systemctl start caddy

6.如果先安装的Caddy后安装的面板,这里需要重启下Caddy

systemctl restart caddy


Comment