开发者
我要评分
获取效率
正确性
完整性
易理解
在线提单
论坛求助

使用反向代理时,必须显式声明受信代理

如必须接入公网或对接企业微信、QQ机器人等,使用反向代理时必须明确声明受信代理,且确保反向代理必须传递真实客户端IP地址。

操作步骤

  • 方式一:
    1. 配置OpenClaw网关的代理服务器IP地址。
      openclaw config set gateway.trustedProxies[0] "127.0.0.1"
      openclaw config set gateway.trustedProxies[1] "::1"
    2. 设置认证模式为trusted-proxy。
      openclaw config set gateway.auth.mode "trusted-proxy"
    3. 设置用户头字段。
      openclaw config set gateway.auth.trustedProxy.userHeader "x-forwarded-user"
    4. 设置允许的用户列表,以user@example.com为例,请根据实际用户修改。
      openclaw config set gateway.auth.trustedProxy.allowUsers[0] "user@example.com"
    5. 重启OpenClaw网关。
      openclaw gateway restart
  • 方式二
    1. 打开配置文件。
      vim ~/.openclaw/openclaw.json
    2. 按“i”进入编辑模式,请添加如下内容。
        "gateway": {
          "auth": {
            "mode": "trusted-proxy",
            "trustedProxy": {
              "userHeader": "x-forwarded-user",
              "allowUsers": [
                "user@example.com"
              ]
            }
          },
          "trustedProxies": [
            "127.0.0.1"
          ]
        }
    3. 按“Esc”键退出编辑模式,输入:wq!,按“Enter”键保存并退出文件。
    4. 重启OpenClaw网关。
      openclaw gateway restart