hexo+butterfly下Twikoo配置

官方文档https://twikoo.js.org/backend.html#%E7%A7%81%E6%9C%89%E9%83%A8%E7%BD%B2-docker

docker安装twikoo

  1. 拉取镜像
docker pull imaegoo/twikoo
  1. 创建twikoo目录并进入
mkdir twikoo

cd twikoo
  1. 运行启动命令
docker run --name twikoo -e TWIKOO_THROTTLE=1000 -p 8080:8080 -v ${PWD}/data:/app/data -d imaegoo/twikoo

配置nginx反向代理和ssl证书

  1. 进入/etc/nginx/sites-available/,创建twikoo并编辑
cd /etc/nginx/sites-available/

vim twikoo
upstream twi {
server localhost:8080;
}

server {
listen 80;
server_name 你的twikoo域名;

location / {
return 301 https://$host$request_uri;
}
}

server {
listen 443 ssl;
server_name 你的twikoo域名;

ssl_certificate ssh证书目录;
ssl_certificate_key ssh证书目录;
ssl_session_timeout 5m;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;

location / {
proxy_pass http://localhost:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}

  1. 配置链接并重启nginx
sudo ln -s /etc/nginx/sites-available/twikoo.conf /etc/nginx/sites-enabled/
sudo systemctl reload nginx
  1. 验证
curl -v twikoo域名
  1. 返回下列值为成功
{"code":100,"message":"Twikoo 云函数运行正常,请参考 https://twikoo.js.org/frontend.html 完成前端的配置","version":"1.6.38"}

前端配置twikoo

  1. 更改buttergly配置
twikoo:
envId:你的twikoo域名
region: #默认ap-shanghai
visitor: false #是否显示文章阅读数
option:可选
  1. 打开博客,点击评论区右下角齿轮进入配置界面