nginx/discourse.conf の編集方法
再構築を行うと、コンテナ内の discourse.conf に対する変更はすべて元に戻されると想定されます。
変更を保持するには、コンテナ構成に何らかの方法で追加する必要があります。たとえば、web_only.yml に追加します。
# [...]
## YAML構文であることを忘れないでください。名前付きブロックは1つしか使用できません。
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 Web コンテナの Nginx]
したがって、エラーが発生した場合は、まず特定する必要があります。
- 外部プロキシ
- Discourse コンテナの Nginx
- Discourse 自体
外部プロキシ
- ブラウザで呼び出して結果を確認します。
- 外部プロキシのエラーログを確認します。
Discourse コンテナの Nginx
- Web サーバーに SSH で接続します。
curlを使用してソケットに直接接続します。curlの出力とDiscourse コンテナの Nginxのログをデバッグします。
重要: https ではなく http URL を使用してください。
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