如何允许 websockets 到 nginx 代理后面的特定子域?

How to allow websockets to specific subdomain behind an nginx proxy?

我有一个 Digital Ocean 服务器 运行 Ubuntu 14.04,还有两个 Web 应用程序 运行 通过 Docker 容器。一个是 Ghost 容器,另一个是 Jupyter 容器 (https://hub.docker.com/r/jupyter/notebook/). I'm also running an nginx-proxy container (https://github.com/jwilder/nginx-proxy)。

问题是 websockets 不工作,Jupyter 要求启用它们才能工作。我在 http://notes.rooday.com/, and accessing it works, but it can't connect to the ipython kernel due to the disabled websockets. I tried researching how to fix this, and the closest I got was this nginx config file https://paste.ubuntu.com/5620850/.

服务了 Jupyter

但是,我不确定如何将该配置文件应用到 nginx-proxy 容器,尤其是在不会干扰我的 Ghost 容器的情况下,该容器也在 nginx-proxy 后面(在 http://blog.rooday.com/).

有人能指出我正确的方向吗?

听起来你想要做的是为 jwilder/nginx-proxy 容器中的一个虚拟主机添加一个自定义 Nginx 配置文件。

根据 jwilder/nginx-proxy container documentation1 你必须挂载一个包含 Nginx 配置文件的卷。为此,请将以下内容添加到您的 docker run 命令

-v /path/to/vhost.d:/etc/nginx/vhost.d:ro

然后在您的机器上 /path/to/vhost.d 创建一个名为 notes.rooday.com 的文件并添加您的自定义 Nginx 配置。


  1. 一直在底部,页眉:"Custom Nginx Configuration.Per-VIRTUAL_HOST"

忘记编辑它了,因为我发现了真正的问题(Andy Shinn 是正确的,这不是配置问题)。

实际问题不是我的任何 docker 容器,甚至不是 Digital Ocean 服务器本身的任何问题,而是 Cloudflare 的问题。 Cloudflare 尚不支持 Websockets,因此任何使用它们的域都必须在 Cloudflare DNS 面板中显示为灰色。

Reference