Discourse突然无法访问了

你好!

我的 Discourse 实例无法正常工作了(我这边没有进行任何操作)。

在 production.log 中,我收到了以下消息:
Error connecting to Redis on localhost:6379 (Errno::ENETUNREACH) subscribe failed,

目前我尝试过的方法:

  • 重启服务器
  • 更新 Docker + 重启服务器 + 重建应用

我对 Docker 和 Discourse 还比较陌生,所以不知道还能做些什么 :frowning:

主机操作系统:CentOS 7
代理:Apache
Docker:最新版本

主机上安装了 fail2ban 和 firewalld。
在 firewalld 日志中,我看到了奇怪的条目:

2020-07-23 14:00:52 WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w10 -t filter -X DOCKER-ISOLATION-STAGE-1' failed: iptables: No chain/target/match by that name.

2020-07-23 14:00:52 WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w10 -t filter -F DOCKER-ISOLATION-STAGE-2' failed: iptables: No chain/target/match by that name.

2020-07-23 14:00:52 WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w10 -t filter -X DOCKER-ISOLATION-STAGE-2' failed: iptables: No chain/target/match by that name.

2020-07-23 14:00:52 WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w10 -t filter -F DOCKER-ISOLATION' failed: iptables: No chain/target/match by that name.

2020-07-23 14:00:52 WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w10 -t filter -X DOCKER-ISOLATION' failed: iptables: No chain/target/match by that name.

2020-07-23 14:00:53 WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w10 -D FORWARD -i docker0 -o docker0 -j DROP' failed: iptables: Bad rule (does a matching rule exist in that chain?).

2020-07-23 14:00:53 WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w10 -D FORWARD -i docker0 -o docker0 -j DROP' failed: iptables: Bad rule (does a matching rule exist in that chain?).

任何帮助或建议都将不胜感激 :slight_smile:
提前致谢!

2 个赞

这看起来是 iptables 和 Docker 相关的问题。请搜索这些关键词。这不是 Discourse 的问题。

2 个赞

我猜 Redis 问题更可能与 Discourse 相关,而不是 iptables 或 Docker,对吗?

这向我表明 Docker 网络已损坏,因此即使 Discourse 和 Redis 运行正常,Discourse 也无法访问 Redis,因为网络或 Docker 本身存在问题。

我猜测这些问题是在你安装 firewalld 后出现的,正是它导致你的安装失败。

2 个赞

谢谢 Jay。

我停止了 firewalld 守护进程,重启了 Docker 和故障容器,但错误依旧(在 production.log 中):

Error connecting to Redis on localhost:6379 (Errno::ENETUNREACH) subscribe failed, reconnecting in 1 second.

我连接到了 Docker 容器:

docker exec --privileged -it <container id> bash

可以看到 Redis 正在运行:

redis 45 0.2 0.1 45936 4352 ? Sl 05:29 0:02 /usr/bin/redis-server *:6379

有什么建议吗?

我已经取得了一些进展。我的配置使用 Apache 2.4 作为代理。在配置中,我添加了以下内容:

RemoteIPHeader X-Forwarded-For

用于跟踪原始 IP 地址。
重启 httpd 后,我成功访问了 Discourse(但收到了 SSL 证书过期的警告)。我也已经解决了该问题,现在一切运行正常,只是需要禁用 firewalld。

我找到了许多关于 CentOS 7 上 Docker 与 firewalld 之间问题的帖子。因此,我将切换回 iptables。

关于 Redis 错误消息,在完成上述步骤后,该错误仅在 Docker 停止时出现。在重启时并未显示,因此我认为这没有问题。

谢谢!

2 个赞

读完这个之后,我在我们的CentOS服务器上停止了Docker

systemctl stop docker

然后启动了它

systemctl start docker

问题解决了。

谢谢@pfaffman

1 个赞