2

I've just recently started setting up my own Ubuntu v16 server on 100tb.com. I'm using Caddy to serve my webpages and give my website an SSL certificate for https. I've installed the Cloudflare version of Caddy on set up and have everything configured according to this article. I have a friend who walked me through setting up Cloudflare so I'm certain it's configured right as well.

The error I'm getting when I restart Caddy is: caddy[14965]: Activating privacy features...2018/01/17 17:10:18 CloudFlare credentials missing

And then Caddy enters a failed state and my website will not show up. I've tried many things. I've manually put the CLOUFLARE_EMAIL and CLOUDFLARE_API_KEY into my environment file. I've used both env and export to add the credentials to my path variable. When I run echo $path they show up in my path (maybe I put them in wrong tho?). When I run echo $CLOUDFLARE_EMAIL it prints it out to the command line like myemail@example.com and same for echo $CLOUDFLARE_API_KEY.

I've looked at Caddy's documentation and other people's questions but none had the answer. I'm not sure why I keep getting this error, I feel like I've done everything correctly. Thanks in advance for any help/insights you have.

Here is my CaddyFile:

www.example.com {
    root /var/www
    gzip
    log /var/www/access.log
    errors /var/www/errors.log
    tls {
        dns cloudflare
    }
}
4

2 回答 2

2

您无需编辑任何内容,只需在执行 caddy 服务之前放置环境变量即可。

export CLOUDFLARE_EMAIL="YOUR_EMAIL_ON_CLOUDFLARE"
export CLOUDFLARE_API_KEY="YOUR_API_KEY_ON_CLOUDFLARE"

检查它是否正确保存

echo $CLOUDFLARE_EMAIL
echo $CLOUDFLARE_API_KEY

然后,在同一个终端运行

sudo CLOUDFLARE_EMAIL=$CLOUDFLARE_EMAIL CLOUDFLARE_API_KEY=$CLOUDFLARE_API_KEY /usr/local/bin/caddy --agree

等待几秒钟让挑战完成,您应该会看到如下输出:

Activating privacy features... done.
https://example.com
http://example.com

这个回复给了我一个提示。https://caddy.community/t/caddy-and-cloudflare-authentication/3080/4

于 2018-11-19T13:37:02.340 回答
1

我通过编辑 caddy.service 文件来解决这个问题,在/etc/systemd/system/caddy.service添加Environment=CLOUDFLARE_API_KEY=xxxxxEnvironment=CLOUDFLARE_EMAIL=xxxxx下面已经存在的文件下,然后Environment=CADDYPATH=xxxxx做了一个. 运行显示caddy正在运行并成功获得ssl证书,使我的网站成为https。sudo systemctl daemon-reloadsudo systemctl restart caddysudo systemctl status caddy.service

资源

于 2018-01-17T22:01:31.003 回答