最近我将我的戴尔服务器从一个位置迁移到了另一个位置。其主操作系统/虚拟机管理器是 Proxmox VE 5.3。我有一台运行 Nginx 的虚拟机,作为反向代理为其他几台虚拟机提供服务,其中一台是 Discourse 虚拟机。
在配置新路由器后,我成功让多台虚拟机连接到了互联网(甚至无需更新 SSL 证书)。然而,在尝试通过浏览器访问 Discourse 时,我收到了 502 Bad Gateway - nginx/1.14.0 (Ubuntu) 错误。
我之前遇到过这个错误,通常以下方法之一可以解决:
重启 Discourse 虚拟机
浏览器中仍然显示 502 Bad Gateway - nginx/1.14.0 (Ubuntu)。
清除浏览器 Cookie 并尝试不同浏览器
以防是本地问题……并非如此。在各种浏览器中仍然出现相同的 502 Bad Gateway - nginx/1.14.0 (Ubuntu) 错误。
Discourse 清理并检查磁盘空间
初次清理时,它删除了约 4 GB 的数据。这让我非常惊讶。也许这才是导致问题的根源?无论如何,现在当我尝试清理 Discourse 时:
> root@forum:/var/discourse# ./launcher cleanup
> WARNING! This will remove all stopped containers.
> Are you sure you want to continue? [y/N] y
> Total reclaimed space: 0B
> WARNING! This will remove all images without at least one container associated to them.
> Are you sure you want to continue? [y/N] y
> Total reclaimed space: 0B
我还要重申,我的磁盘空间并未耗尽:
Git Pull
已是最新版本。
> root@forum:/var/discourse# git pull
> Already up to date.
重启 Discourse
在这里,我发现了两个错误:
> root@forum:/var/discourse# ./launcher restart app
>
> WARNING: We are about to start downloading the Discourse base image
> This process may take anywhere between a few minutes to an hour, depending on your network speed
>
> Please be patient
>
> Unable to find image 'discourse/base:2.0.20191013-2320' locally
> /usr/bin/docker: Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers).
> See '/usr/bin/docker run --help'.
> Your Docker installation is not working correctly
>
> See: `https://meta.discourse.org/t/docker-error-on-bootstrap/13657/18?u=sam`
我查看了建议的链接。它推荐执行 Git Pull 并 重建 Discourse(稍后你会看到我的结果)。它还建议运行 Docker “Hello World” 命令。该命令可以运行(但似乎存在一些问题?):
> root@forum:/var/discourse# docker run -it --rm hello-world
> Unable to find image 'hello-world:latest' locally
> latest: Pulling from library/hello-world
> 1b930d010525: Pull complete
> Digest: sha256:c3b4ada4687bbaa170745b3e4dd8ac3f194ca95b2d0518b417fb47e5879d9b5f
> Status: Downloaded newer image for hello-world:latest
>
> Hello from Docker!
> This message shows that your installation appears to be working correctly.
>
> To generate this message, Docker took the following steps:
> 1. The Docker client contacted the Docker daemon.
> 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
> (amd64)
> 3. The Docker daemon created a new container from that image which runs the
> executable that produces the output you are currently reading.
> 4. The Docker daemon streamed that output to the Docker client, which sent it
> to your terminal.
>
> To try something more ambitious, you can run an Ubuntu container with:
> $ docker run -it ubuntu bash
>
> Share images, automate workflows, and more with a free Docker ID:
> https://hub.docker.com/
>
> For more examples and ideas, visit:
> https://docs.docker.com/get-started/
>
> failed to resize tty, using default size
接下来,我尝试了 Ubuntu Bash……结果报错:
> root@forum:/var/discourse# docker run -it ubuntu bash
> Unable to find image 'ubuntu:latest' locally
> docker: Error response from daemon: Get https://registry-1.docker.io/v2/library/ubuntu/manifests/latest: Get https://auth.docker.io/token?scope=repository%3Alibrary%2Fubuntu%3Apull&service=registry.docker.io: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers).
> See 'docker run --help'.
现在尝试其他已知方法:
停止并启动 Discourse
收到的错误与 重启 时相同:
> root@forum:/var/discourse# ./launcher stop app
>
> WARNING: We are about to start downloading the Discourse base image
> This process may take anywhere between a few minutes to an hour, depending on your network speed
>
> Please be patient
>
> Unable to find image 'discourse/base:2.0.20191013-2320' locally
> /usr/bin/docker: Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers).
> See '/usr/bin/docker run --help'.
> Your Docker installation is not working correctly
>
> See: `https://meta.discourse.org/t/docker-error-on-bootstrap/13657/18?u=sam`
>
> root@forum:/var/discourse# ./launcher start app
>
> WARNING: We are about to start downloading the Discourse base image
> This process may take anywhere between a few minutes to an hour, depending on your network speed
>
> Please be patient
>
> Unable to find image 'discourse/base:2.0.20191013-2320' locally
> /usr/bin/docker: Error response from daemon: Get https://registry-1.docker.io/v2/discourse/base/manifests/2.0.20191013-2320: Get https://auth.docker.io/token?scope=repository%3Adiscourse%2Fbase%3Apull&service=registry.docker.io: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers).
> See '/usr/bin/docker run --help'.
> Your Docker installation is not working correctly
>
> See: `https://meta.discourse.org/t/docker-error-on-bootstrap/13657/18?u=sam`
重建 Discourse
再次出现相同的两个错误。
> root@forum:/var/discourse# ./launcher rebuild app
>
> WARNING: We are about to start downloading the Discourse base image
> This process may take anywhere between a few minutes to an hour, depending on your network speed
>
> Please be patient
>
> Unable to find image 'discourse/base:2.0.20191013-2320' locally
> /usr/bin/docker: Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers).
> See '/usr/bin/docker run --help'.
> Your Docker installation is not working correctly
>
> See: https://meta.discourse.org/t/docker-error-on-bootstrap/13657/18?u=sam
从之前的备份恢复
我有一份在迁移服务器和清理(如前所述,清理了约 4 GB 文件)之前创建的快照。我再次尝试了上述所有操作……结果相同(除了 清理 步骤),浏览器中仍然显示 502 Bad Gateway - nginx/1.14.0 (Ubuntu)。因此,也许这与清理无关?
在我使用 Discourse 的整个过程中,从未遇到过这两个错误。有什么建议可以帮助我解决这些错误,让 Discourse 在浏览器中正常运行吗?
