233boy / v2ray

最好用的 V2Ray 一键安装脚本 & 管理脚本
https://233boy.com/v2ray/v2ray-script/
GNU General Public License v3.0
24.72k stars 16.17k forks source link

一键脚本安装后,开启ws+tls后,如何配置caddy使用cloudflare的证书? #525

Closed bglmmz closed 1 year ago

bglmmz commented 4 years ago
  1. 安装了caddy的cloudflare插件(安装中/usr/local/bin/canddy执行文件被修改了),命令是:

curl https://getcaddy.com | bash -s personal tls.dns.cloudflare

  1. 编辑/etc/environment, 添加如下类似代码:
export CLOUDFLARE_EMAIL=xxxxx@gmail.org
export CLOUDFLARE_API_KEY=xxxxxxxxxxxxxxxxxxxxxxx
  1. 修改的/etc/caddy/Caddyfile 其中xxxxxxx.tk是我的域名,/var/www/xxxxxxx.tk是我的网站的根路径
xxxxxxx.tk {
    tls {
        dns cloudflare
    }
    root /var/www/xxxxxxx.tk
    gzip
    log /var/log/caddy.log
    timeouts none
    proxy /sitemap 127.0.0.1:65275 {
        websocket
    }
}
import sites/*
  1. reboot后,输入命令:systemctl status caddy,出现如下2个错误信息: a. ExecStart=/usr/local/bin/caddy -log stdout -log-timestamps=false -agree=true -conf=/etc/caddy/Caddyfile -root=/var/tmp (code=exited, status=1/FAILURE)

    b. /etc/caddy/Caddyfile:3 - Error during parsing: Setting up DNS provider 'cloudflare': cloudflare: some credentials

● caddy.service - Caddy HTTP/2 web server
   Loaded: loaded (/lib/systemd/system/caddy.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sun 2020-03-15 00:20:09 CST; 23min ago
     Docs: https://caddyserver.com/docs
  Process: 1293 ExecStart=/usr/local/bin/caddy -log stdout -log-timestamps=false -agree=true -conf=/etc/caddy/Caddyfile -root=/var/tmp (code=exited, status=1/FAILURE)
 Main PID: 1293 (code=exited, status=1/FAILURE)

Mar 15 00:20:08 instance-1 systemd[1]: Started Caddy HTTP/2 web server.
Mar 15 00:20:09 instance-1 caddy[1293]: [INFO] Caddy version: v1.0.4
Mar 15 00:20:09 instance-1 caddy[1293]: [WARNING] No files matching import glob pattern: sites/*
Mar 15 00:20:09 instance-1 caddy[1293]: [INFO][cache:0xc00008c870] Started certificate maintenance routine
Mar 15 00:20:09 instance-1 caddy[1293]: /etc/caddy/Caddyfile:3 - Error during parsing: Setting up DNS provider 'cloudflare': cloudflare: some credentials
Mar 15 00:20:09 instance-1 systemd[1]: caddy.service: Main process exited, code=exited, status=1/FAILURE
Mar 15 00:20:09 instance-1 systemd[1]: caddy.service: Unit entered failed state.
Mar 15 00:20:09 instance-1 systemd[1]: caddy.service: Failed with result 'exit-code'.
  1. 请问,Caddyfile如何配置,才能用上cloudflare的证书?才能正确启动?谢谢!!
bglmmz commented 4 years ago

关于caddy的root配置,我通过修改如下配置文件解决了: /lib/systemd/system/caddy.service

但是tls问题还是没有解决,参考: https://github.com/233boy/v2ray/issues/353 里面有位仁兄的解决方法,https和http 分开两份配置。 也是不起作用,caddy启动报错,说找不到证书: Error during parsing: Unable to load certificate and key files for 'xxxxxx.tk': open /etc/ssl/***

我看/lib/systemd/system/caddy.service里,有关于caddy的ssl路径,是/etc/ssl/caddy,难道是证书文件和私钥文件要放这里?但是看/etc/ssl/caddy的目录解构,不知道该怎么放,所以就没有试。。。

ntgeralt commented 4 years ago

如果想走cf cdn,可以搭80 ws服务端,然后配合 cf worker实现走cdn https://www.529i.com/archives/772.html

wanghaisheng commented 4 years ago

@bglmmz 看看这个 我也没调好https://github.com/kullex/v2dock