新コミュニティのステージング:Basic AuthでWP-Discourseプラグインが動作しない

WordPress と Discourse のサイト (セルフホスト) を WP-Discourse プラグインを使用してステージングしています。

両方のサイトで HTTP 基本認証を正常に有効にし、公開準備が整うまでアクセスできないようにしました (一般公開および検索エンジンからのアクセスを効果的にブロックします)。

WordPress (同様のことを行いたい人のための情報)

Discourse

WP-Discourse プラグインは、Discourse サーバーで基本認証が有効になるまで正常に機能します。

(編集) これは、WordPress 側の WP-Discourse プラグインログのエラーです: [2025-02-14 18:20:06] connection.INFO: check_connection_status.failed_to_connect {"error":"wpdc_response_error","message":"An invalid response was returned from Discourse","http_code":401,"http_body":"\u003chtml\u003e\r\n\u003chead\u003e\u003ctitle\u003e401 Authorization Required\u003c/title\u003e\u003c/head\u003e\r\n\u003cbody\u003e\r\n\u003ccenter\u003e\u003ch1\u003e401 Authorization Required\u003c/h1\u003e\u003c/center\u003e\r\n\u003chr\u003e\u003ccenter\u003enginx\u003c/center\u003e\r\n\u003c/body\u003e\r\n\u003c/html\u003e\r\n"}

Discourse で HTTP 基本認証を必要としないように API を除外する方法について、何か考えはありますか?

ありがとうございます!

本当にそうでしょうか? Discourse が基本認証で動作するかどうか、私は確信が持てません。一度試しましたが、諦めました。wp-discourse がさらに壊れる可能性が高いようです(そして、そのことについては正しかった!)。もし成功していたら、このメッセージを書いているはずがありません。:wink:

Discourse のステージングサイトでは、通常「ログイン必須」を設定するだけで、検索エンジンを遠ざけることができます。ログインできる人はログインできますが、通常はそれが望ましいことです。

サイトが誰でも利用可能であることが許容できない場合は、ファイアウォールを使用して IP アドレスへのアクセスを制限することを検討してください。

基本認証に、Discourse サーバーの IP からのアクセスを許可するように指示できますか? たぶん:Allow access from one IP, require basic auth from all other sources - Traefik v2 - Traefik Labs Community Forum

ありがとうございます。この手がかりのおかげで問題を解決できました。以下は、私のDiscourseサーバーのapp.ymlの更新された基本的な認証セクションです(Wordpressサーバーに変更は必要ありませんでした)。

# basic auth
  after_bundle_exec:
    - replace:
       filename: "/etc/nginx/conf.d/discourse.conf"
       from: "# Allow bypass cache from localhost"
       to: |
            # Allow bypass basic authentication for WP-Discourse plugin
            geo $authentication {
            default "Credentials you must provide.";
            127.0.0.1 "off";
            151.101.3.55/32 "off";
            }
            # Allow bypass cache from localhost
    - replace:
       filename: "/etc/nginx/conf.d/discourse.conf"
       from: "# auth_basic on"
       to: "auth_basic $authentication"
    - replace:
       filename: "/etc/nginx/conf.d/discourse.conf"
       from: "# auth_basic_user_file /etc/nginx/htpasswd"
       to: "auth_basic_user_file /etc/nginx/htpasswd"
    - replace:
       filename: "/etc/nginx/conf.d/discourse.conf"
       from: "location = /srv/status {"
       to: "location = /srv/status {
           auth_basic off;"
    - file:
       path: "/etc/nginx/htpasswd"
       contents: |
         alfred:$apr1$jSdLuHyZ$faWxYGjnmLd/zRC6UMsRs1

151.101.3.55は私のWordpressサーバーの(例としての)パブリックIPアドレスです。WP-Discourseは現在次のように報告しています。
A blank screen displays the green-bordered text, "You are connected to Discord!" (Captioned by AI)

「いいね!」 2

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.