Caddy 2.0 http2_error SSL握手失敗,unexpected end of JSON input

瀏覽器打開站點(diǎn)突然冒出net::HTTP2_ERROR之類,站點(diǎn)是套了一層鵝廠的CDN。
連忙登錄SSH,發(fā)現(xiàn)Caddy2 并沒有重啟過。
Caddyfile里加上

#頂部加上啊,表示開啟調(diào)試日志,輸出更加詳細(xì)
{
debug
}

扒一扒Caddy2日志

{"level":"warn","ts":1591004115.321159,"msg":"$HOME environment variable is empty - please fix; some assets might be stored in ./caddy"}
[ERROR] xxx.cn: caching certificate after obtaining it: decoding certificate metadata: unexpected end of JSON input
{"level":"info","ts":1591004115.3211713,"logger":"watcher","msg":"watching config file for changes","config_file":"/home/xxx/caddy/Caddyfile"}
[ERROR] xxx.cn: caching certificate after obtaining it: decoding certificate metadata: unexpected end of JSON input
[ERROR] xxx.cn: caching certificate after obtaining it: decoding certificate metadata: unexpected end of JSON input
[ERROR] xxx.cn: caching certificate after obtaining it: decoding certificate metadata: unexpected end of JSON input
[ERROR] xxx.cn: caching certificate after obtaining it: decoding certificate metadata: unexpected end of JSON input
[ERROR] xxx.cn: caching certificate after obtaining it: decoding certificate metadata: unexpected end of JSON input
[ERROR] xxx.cn: caching certificate after obtaining it: decoding certificate metadata: unexpected end of JSON input
[ERROR] xxx.cn: caching certificate after obtaining it: decoding certificate metadata: unexpected end of JSON input

我突然想起來服務(wù)器前幾天把默認(rèn)SHELL切換為Zsh,退出SSH會話后which pm2直接搜不到了,坑爹啊
注意啦,這里講一下,Zsh不加載 Bash默認(rèn)加載的文件,也就是↓

 /etc/environment
/etc/profile
~/.bashrc
等等

Zsh默認(rèn)加載↓

/etc/zsh/zshenv
/etc/zsh/zshprofile
/etc/zsh/zshrc
/etc/zsh/zshlogin
/etc/zsh/zshlogout
~/.zhrc
~/.zshenc
等等...和上面差不多,都在用戶目錄,不一定全都存在,不存在的話你可以手動創(chuàng)建

切換到Zsh后,你可以復(fù)制一份原先Bash里的配置的環(huán)境變量到Zsh默認(rèn)加載的變量文件里(沒錯,我就是用這種方式),
另外一種方法就是在Zsh啟動加載的文件里寫上source /etc/profile,(注意了注意了,這個我沒有實(shí)際驗(yàn)證過有咩有效果)

回到Caddy v2,我在Zshecho $HOME 輸出/root也沒毛病啊,難道是我用supervisord的原因???,果然如此。

最終解決辦法

supervisord.conf

[program:caddy2]
command=/home/xxx/caddy/caddy run  --config /home/xxx/caddy/Caddyfile --watch
autorestart=true
autostart=true
startsecs=5
;**注意了就是這行解決了decoding certificate metadata: unexpected end of JSON input**
environment=HOME="/root"
directory=/home/xxx/caddy/
stdout_logfile=/tmp/caddy2.log
stdout_logfile_maxbytes=1MB
stderr_logfile=/tmp/caddy2.err.log
stderr_logfile_maxbytes=1MB

相關(guān)問題:
Caddy2 SSL握手失敗,SSL握手錯誤?
Caddy2 http2_error怎么辦?
Caddy2無法加載證書啊?
Caddy2 TLS handshake error from xxx no certificate available?
Caddy2 SSL內(nèi)部錯誤?

Caddy v1和v2配置文件差異挺大的,改天寫篇文章來詳細(xì)說明一下,大家可以翻翻參照一下。

本文章原創(chuàng)。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容