谢谢你,Jay @pfaffman ,
你绝对是这里最顶尖、最有价值的资源,毫无疑问!
你觉得这个可能有点疯狂的想法怎么样(基于我目前有限的理解):
在前端设置 nginx 作为反向代理;参考这个教程:
This guide is intended for advanced users, who are already using nginx outside the docker container. By following this guide you make your setup more complicated and will lose some speed benefits like HTTP2 if you’re not running Ubuntu 16.04 or later. Proceed with caution!
When Discourse is rebuilding or starting up, your users will usually either see an error message from their browser…
[image]
…or a not-so-nice 502 error message from Nginx:
[image]
If you’re a perfectionist …
然后设置两个目录/实例,使用 discourse_docker(独立模式),例如:
/var/discourse1
/var/discourse2
在这两个实例中,将 discourse_docker(独立模式)配置为监听不同的套接字,修改每个实例中的以下模板:
- "templates/web.socketed.template.yml"
简而言之,我们只需在某个安静时段重建生产环境,使其在另一个容器中运行并监听不同的套接字(nginx.https.sock2),这样就不会有套接字冲突;我们也可以以独立模式构建(目标是消除对两个容器(data 和 web-only)的需求)。
例如(用于讨论/说明),在 discourse1 的 web.socketed.template.yml 中:
- replace:
filename: "/etc/nginx/conf.d/discourse.conf"
from: /listen 80;/
to: |
listen unix:/shared/nginx.http.sock;
set_real_ip_from unix:;
- replace:
filename: "/etc/nginx/conf.d/discourse.conf"
from: /listen 443 ssl http2;/
to: |
listen unix:/shared/nginx.https.sock ssl http2;
set_real_ip_from unix:;
而在 discourse2 中:
- replace:
filename: "/etc/nginx/conf.d/discourse.conf"
from: /listen 80;/
to: |
listen unix:/shared/nginx.http.sock2;
set_real_ip_from unix:;
- replace:
filename: "/etc/nginx/conf.d/discourse.conf"
from: /listen 443 ssl http2;/
to: |
listen unix:/shared/nginx.https.sock2 ssl http2;
set_real_ip_from unix:;
不过,与其让 discourse 模板自动完成这些操作,我们只需手动切换 /etc/nginx/conf.d/discourse.conf 中的套接字并重启 nginx,这样就可以从 web.socketed.template.yml 模板中移除 replace: 指令。
在这个提议的(可能有点疯狂)配置中,我们可以让两个独立容器监听两个不同的套接字(互不冲突),只需配置 nginx 连接到所需的套接字并重启 nginx 即可。
这看起来清晰、简单,或许对某些不想(或不需要)为单个 discourse 实例(应用)维护两个容器(data 和 web-only)复杂性的用户来说很有用(特别是在实时实例没有新帖子的空闲时段)。
当然,从数据角度来看,最稳健的配置(尤其是对于繁忙的网站)仍然是“双容器”方案,因为我们会希望 data 和 web-only 实例(现在分别监听两个不同的套接字:sock 和 sock2)。
在带有 nginx 前端的“双容器”方案中,“标准配置”是让两个 web-only 容器监听同一个套接字,因此它们不能同时运行;但如果(仅举例)让它们监听不同的套接字,它们就可以同时运行,我们只需使用 nginx 配置文件(并重启 nginx)即可在两者之间切换。
我的理解正确吗?
我是不是正在(虽然缓慢但希望稳步地)理解这一切?
谢谢!
仅作为补充说明: 我已经在其中一台桌面 Mac 上成功配置了“双容器”方案:
我们安装过程中唯一的注意事项是必须手动创建这些目录(并设置所有权和权限),因为这些目录出于某种原因没有被脚本自动创建:
~discourse/discourse/shared/data
~discourse/discourse/shared/web-only
当然,一开始我尝试使用空密码连接数据库,但失败了(虽然说明中确实提到要设置密码,但我当时只是在尝试)。
接下来,我将设置 nginx 前端,并尝试将 web-only 应用切换到该配置,使用 websocket。