You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用HTTPS时Parse-Dashboard遇‘Server not reachable: unauthorized’报错求助

问题描述

已在Ubuntu服务器成功部署Parse-Server,可通过https://www.example.com/parse正常访问。配置详情如下:

Parse-Server配置

{
  "appId": "app",
  "clientKey": "client",
  "masterKey": "master",
  "appName": "MyParseApp",
  "cloud": "./cloud/main",
  "serverURL": "https://www.example.com/parse",
  "masterKeyIps": [my_ips],
  "databaseURI": "postgres://postgres:password@localhost:5432/postgres"
}

Apache虚拟主机配置(example.com)

<VirtualHost *:80>
    DocumentRoot /var/www/html/example.com

    ServerName example.com
    ServerAdmin admin@example.com

    ErrorLog /var/log/apache2/example.com/http_error.log
    CustomLog /var/log/apache2/example.com/http_access.log combined
</VirtualHost>
<VirtualHost *:443>
        DocumentRoot /var/www/html/example.com

        ServerName example.com
        ServerAdmin admin@example.com
    ServerAlias example.com

        ErrorLog /var/log/apache2/example.com/https_error.log
        CustomLog /var/log/apache2/example.com/https_access.log combined

    SSLEngine on
    SSLCertificateFile /etc/certificate/example.com.cer
    SSLCertificateKeyFile /etc/certificate/example.com.key
    
    SSLProxyEngine On
    ProxyRequests Off
    ProxyPass /parse http://localhost:1337/parse
    ProxyPassReverse /parse http://localhost:1337/parse
    ProxyPass /dashboard http://localhost:4040/dashboard
    ProxyPassReverse /dashboard http://localhost:4040/dashboard

    ProxyPreserveHost On
</VirtualHost>

Parse-Dashboard配置与启动

通过命令nohup parse-dashboard --dev --config parse-dashboard-config.json &启动,配置如下:

{
  "apps": [
    {
      "appId": "app",
      "masterKey": "master",
      "appName": "MyParseApp",
      "iconName": "",
      "primaryBackgroundColor": "",
      "secondaryBackgroundColor": "",
      "serverURL": "https://www.example.com/parse"
    }
  ],
  "users": [
    {
        "user": "username",
        "pass": "password"
    }
  ],
  "iconsFolder": "icons"
}

核心问题

  • 可正常访问Dashboard,但将serverURL设为https://www.example.com/parse时,触发**"Server not reachable: unauthorized"**错误
  • 改为http://www.example.com:1337/parse则可正常访问并操作数据
  • 已尝试添加allowInsecureHTTP: true,未解决问题

解决方案

1. 修复Apache代理的请求头传递

HTTPS代理到本地HTTP服务时,Apache需正确传递协议和主机头,否则Parse-Server无法识别请求合法性。修改443虚拟主机配置:

<VirtualHost *:443>
    <!-- 保留原有配置 -->
    
    SSLProxyEngine On
    ProxyRequests Off
    
    # 添加以下两行,传递HTTPS协议标识
    RequestHeader set X-Forwarded-Proto "https"
    RequestHeader set X-Forwarded-Host "example.com"
    
    ProxyPass /parse http://localhost:1337/parse
    ProxyPassReverse /parse http://localhost:1337/parse
    ProxyPass /dashboard http://localhost:4040/dashboard
    ProxyPassReverse /dashboard http://localhost:4040/dashboard

    ProxyPreserveHost On
</VirtualHost>

重启Apache生效:

sudo systemctl restart apache2

2. 配置Parse-Server信任代理

在Parse-Server配置中添加trustProxy选项,允许它信任Apache传递的代理头:

{
  // 保留原有配置
  "trustProxy": true,
  "serverURL": "https://www.example.com/parse"
}

重启Parse-Server。

3. 修正Dashboard的allowInsecureHTTP配置位置

allowInsecureHTTP需放在Dashboard配置的根节点,而非app子节点,正确配置:

{
  "apps": [
    {
      "appId": "app",
      "masterKey": "master",
      "appName": "MyParseApp",
      "serverURL": "https://www.example.com/parse"
    }
  ],
  "users": [
    {
        "user": "username",
        "pass": "password"
    }
  ],
  "allowInsecureHTTP": true,
  "iconsFolder": "icons"
}

重启Dashboard(建议去掉--dev生产环境使用):

pkill -f parse-dashboard
nohup parse-dashboard --config parse-dashboard-config.json &

4. 检查masterKeyIps限制

Parse-Server的masterKeyIps需包含服务器本地IP(127.0.0.1),因为Dashboard请求通过代理转发后,源IP为本地:

"masterKeyIps": ["127.0.0.1", "你的其他授权IP"]

内容的提问来源于stack exchange,提问作者Another Dude

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.28 14:17:47