解析仪表板 - 服务器无法访问:无法连接到服务器

解析仪表板 - 服务器无法访问:无法连接到服务器

我在 Azure 上部署了 2 台 Ubuntu 服务器。首先,我安装了 Parse Server,其次,我安装了 MongoDB。(我还在那里放了一个现成的数据库)

一切正常!Parse Server 和 MongoDB 服务器都运行良好。它们之间也能够很好地通信。问题是,当我尝试连接到我的仪表板时 - http://IP:4040/dashboard- 它会抛出错误Server not reachable: unable to connect to server

以下是我的index.js

var express = require('express');
var ParseServer = require('parse-server').ParseServer;
var ParseDashboard = require('parse-dashboard');
var allowInsecureHTTP = true;
var path = require('path');

var databaseUri = process.env.DATABASE_URI || process.env.MONGODB_URI;

if (!databaseUri) {
  console.log('DATABASE_URI not specified, falling back to localhost.');
}

//process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';

var api = new ParseServer({
  databaseURI: databaseUri || 'mongodb://IP:27017/db',
  cloud: './cloud/main.js',
  appId: process.env.APP_ID || 'xxx',
  masterKey: process.env.MASTER_KEY || 'xxx', //Add your master key here. Keep it secret!
  fileKey: 'xxx',  
  serverURL: process.env.SERVER_URL || 'http://localhost:1337/parse',  // Don't forget to change to https if needed

  // Enable email verification
  verifyUserEmails: false,

  // The public URL of your app.
  // This will appear in the link that is used to verify email addresses and reset passwords.
  // Set the mount path as it is in serverURL
  publicServerURL: 'http://localhost:1337/parse',
});

// Client-keys like the javascript key or the .NET key are not necessary with parse-server
// If you wish you require them, you can set them as options in the initialization above:
// javascriptKey, restAPIKey, dotNetKey, clientKey

var app = express();

// Serve static assets from the /public folder
app.use('/public', express.static(path.join(__dirname, '/public')));

// Serve the Parse API on the /parse URL prefix
var mountPath = process.env.PARSE_MOUNT || '/parse';
app.use(mountPath, api);

// Parse Server plays nicely with the rest of your web routes
app.get('/', function(req, res) {
  res.status(200).send('Make sure to star the parse-server repo on GitHub!');
});

// There will be a test page available on the /test path of your server url
// Remove this before launching your app
app.get('/test', function(req, res) {
  res.sendFile(path.join(__dirname, '/public/test.html'));
});

var port = process.env.PORT || 1337;
var httpServer = require('http').createServer(app);
httpServer.listen(port, function() {
    console.log('parse-server-example running on port ' + port + '.');
});

// Set up parse dashboard
var config = {
  "allowInsecureHTTP": true,
  "apps": [
    {
      "serverURL": "http://localhost:1337/parse",
      "appId": "xxx",
      "masterKey": "xxx",
      "appName": "name",
      "production": true
    }
  ],
  "users": [
    {
      "user":"username",
      "pass":"pass"
    }
  ]
};

var dashboard = new ParseDashboard(config, config.allowInsecureHTTP);
var dashApp = express();

// make the Parse Dashboard available at /dashboard
dashApp.use('/dashboard', dashboard);  

// Parse Server plays nicely with the rest of your web routes
dashApp.get('/', function(req, res) {  
  res.status(200).send('Parse Dashboard App');
});

var httpServerDash = require('http').createServer(dashApp);  
httpServerDash.listen(4040, function() {  
    console.log('dashboard-server running on port 4040.');
});

// This will enable the Live Query real-time server
ParseServer.createLiveQueryServer(httpServer);

这是我的package.json

{
  "name": "parse-server-example",
  "version": "1.4.0",
  "description": "An example Parse API server using the parse-server module",
  "main": "index.js",
  "repository": {
    "type": "git",
    "url": "https://github.com/ParsePlatform/parse-server-example"
  },
  "license": "MIT",
  "dependencies": {
    "express": "~4.11.x",
    "kerberos": "~0.0.x",
    "parse": "~1.8.0",
    "parse-server": "~2.6.3",
    "parse-dashboard": "~1.1.0"
  },
  "scripts": {
    "start": "node index.js"
  },
  "engines": {
    "node": ">=4.3"
  }
}

我还从 Azure 仪表板打开了所需的端口。有什么想法吗?我搜索了又搜索,但没有找到。

答案1

默认情况下,我们应该绑定到"serverURL": "http://localhost:1337/parse",但在 Azure 中,我们建议绑定到10.0.0.4 (Azure VM private VM)

在 Azure 中,公共 IP 网络流量将首先路由到 Azure 私有 IP 地址。

答案2

我刚刚将仪表盘配置中的 serverURL 从 改为 ,http://localhost:1337/parse一切http://ip:1337/parse就绪了!这是为什么呢?

相关内容