如何编辑 nginx/discourse.conf
我假设任何对容器内 discourse.conf 的更改都会在重建时被恢复。
要保留更改,您必须以某种方式将其添加到容器配置中——例如,web_only.yml:
# [… ]
## 请记住,这是 YAML 语法——一个名称的块只能有一个
run:
- exec: echo "开始自定义命令"
# [… ]
- replace:
filename: /etc/nginx/conf.d/discourse.conf
from: $proxy_add_x_forwarded_for
to: $http_x_real_ip
global: true
# [… ]
如何调试子文件夹安装的 Discourse
在子文件夹安装的 Discourse 中,对 Discourse 的调用如下所示:
example.org/forum → [example.org 的外部代理] → /path-to-discourse/discourse/shared/web-only/nginx.http.sock → [Discourse 网页容器中的 Nginx]
因此,如果出现错误,我们必须首先找到它:
- 外部代理
- Discourse 容器中的 Nginx
- Discourse 本身
外部代理
- 在浏览器中调用它并检查结果。
- 检查外部代理的错误日志。
Discourse 容器中的 Nginx
- SSH 进入您的网络服务器。
- 使用
curl直接连接到套接字。 - 调试
curl输出和Discourse 中的 Nginx的日志
重要提示:使用 http URL——而不是 https。
curl -I --unix-socket /path-to-discourse/discourse/shared/web-only/nginx.http.sock http://www.example.org/forum/
如果这有效,请尝试一个实际的调用,例如:
curl --unix-socket /path-to-discourse/discourse/shared/web-only/nginx.http.sock \
-H "user-agent: Chrome/88.0.4324.182" \
-H "Accept-Encoding: gzip" \
http://www.example.org/forum/t/test-thread/12345 --output test-encoded.html.gz