之前博客的评论系统一直用的是 Disqus,但是 Disqus 在国内被墙了,必须通过代理才能访问,这导致在国内的体验不是很好。工信部又发通知不允许第三方平台提供非注册用户发表评论跟帖的功能,于是多说、网易云跟帖这些评论平台也快速倒闭。韩国还有一个来必力可以用,但是个人无感。
最终打算使用 Isso 搭建自建评论系统,具体介绍见官网简介,我这里直接记录搭建过程。
安装 Isso
1 2
| yum install sqlite python36-devel python3 -m pip install isso --user
|
配置 Isso
在用户目录下新建一个 isso 文件夹,isso.conf 配置文件(用来配置 isso),其中 isso.conf 的内容示例如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
| [general]
dbpath = /root/isso/data.db
name = blog
host = https://lolimay.cn https://www.lolimay.cn
notify = smtp
log-file = /root/isso/log
[server]
listen = http://localhost:53051/
[moderation]
enabled = false
purge-after = 30d
[smtp]
username = service@lolimay.cn
password = <替换成你的SMTP密码>
host = smtp.qq.com
port = 465
security = ssl
to = shiqi.mei@lolimay.cn
from = "Isso 评论"<service@lolimay.cn>
timeout = 10
[markup]
options = strikethrough, superscript, autolink
allowed-elements =
allowed-attributes =
[guard]
enabled = true
ratelimit = 10
direct-reply = 100
reply-to-self = true
require-author = true
require-email = true
[hash]
salt = Eech7co8Ohloopo9Ol6baimi algorithm = pbkdf2
|
保存配置文件后,就可以启动 isso 看输出消息是否正常:
1
| isso -c ~/isso/isso.conf
|
检查日志文件,查看是否有错误信息:
预期内容如下,如果日志输出不是类似下面这个内容,则需要手动排错:
1 2
| connected to SMTP server connected to https://lolimay.cn
|
配置 Nginx 反向代理 Isso 服务
修改网站的 Nginx 配置,添加代理规则:
1 2 3 4 5 6 7
| location /isso/ { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Script-Name /isso; proxy_set_header Host $host; proxy_set_header X-Forwarded-Proto $scheme; proxy_pass http: }
|
保存后访问,https://lolimay.cn/isso 或者 https://www.lolimay.cn/isso 后显示:
1 2
| Bad Request missing uri query
|
就表示反向代理配置成功了,如果都没问题,就可以 Ctrl+C 先停止 Isso 了。
使用 pm2 部署 Isso
1 2
| pm2 start python3 --name "isso" -- /usr/local/bin/isso -c /root/isso/isso.conf pm2 save # 保存当前进程列表,这样即使系统重启后也会自动恢复
|
在博客源码中引用
1 2 3 4 5 6 7
| <% if (page.comments) { %> <script data-isso="/isso/" src="/isso/js/embed.min.js" data-isso-css="true" data-isso-reply-to-self="true" data-isso-require-author="true" data-isso-require-email="true" data-isso-max-comments-top="10" data-isso-max-comments-nested="5" data-isso-reveal-on-click="5" data-isso-avatar="true" data-isso-avatar-bg="#f0f0f0" data-isso-avatar-fg="#9abf88 #5698c4 #e279a3 #9163b6" data-isso-vote="true" data-vote-levels=""></script> <section id="isso-thread"></section> <% } %>
|
最后重新部署博客不出意外应该就可以看到成果了:

当然,如果你觉得自带的样式太简陋的话可以自己写一点 CSS 覆盖即可。
参考链接
- Debian / Ubuntu 搭建 Isso 评论系统教程