# 打造新社区：Basic Auth导致WP-Discourse插件无法工作

**URL:** <https://meta.discourse.org/t/staging-a-new-community-basic-auth-breaks-wp-discourse-plugin/352368>\
**Category:** WordPress\
**Created:** [2025年二月14日 20:13 UTC](https://meta.discourse.org/t/staging-a-new-community-basic-auth-breaks-wp-discourse-plugin/352368 "2025-02-14T20:13:37Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Todd\_S](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/todd_s/32/484575_2.png) [@Todd\_S](https://meta.discourse.org/u/Todd_S)\
**Post date:** [2025年二月15日 06:04 UTC](https://meta.discourse.org/t/staging-a-new-community-basic-auth-breaks-wp-discourse-plugin/352368/3 "2025-02-15T06:04:05Z")

</div>

> [@pfaffman](#):
>
> 你能否提供一个基础身份验证，允许从 Discourse 服务器的 IP 访问？

谢谢，这个线索帮助我解决了问题。这是我的 Discourse 服务器上 `app.yml` 的更新后的基础身份验证部分（Wordpress 服务器上无需更改）：

```plaintext
# 基础身份验证
  after_bundle_exec:
    - replace:
       filename: "/etc/nginx/conf.d/discourse.conf"
       from: "# Allow bypass cache from localhost"
       to: |
            # 允许 WP-Discourse 插件绕过基础身份验证
            geo $authentication {
            default "您必须提供的凭据。";
            127.0.0.1 "off";
            151.101.3.55/32 "off";
            }
            # 允许绕过本地缓存
    - 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 现在报告：  
 ![AI 标注的空白屏幕显示绿边文字“您已连接到 Discord！”](https://global.discourse-cdn.com/meta/original/4X/d/d/e/ddee353078be2b34e77121a5c7fe4550e50d0cdb.png)

---

_[View the full topic](https://meta.discourse.org/t/staging-a-new-community-basic-auth-breaks-wp-discourse-plugin/352368)._
