0

我已经在 Ubuntu 上部署了 Realm Object Server v2.0.4 并且还实现了 LetsEncrypt。我可以使用新的 Realm Studio 进行连接——一切似乎都很好。

现在基本服务器已经到位,我需要将其配置为使用 HTTPS 并禁用 HTTP——这就是我苦苦挣扎的地方。

我使用ros init bb(bb 只是一个临时项目名称)创建了一个新的 Realm 项目,文件夹结构如下所示:

bb
└───src
│   │   index.ts

我已更新index.ts以包含以下内容:

import { BasicServer } from 'realm-object-server'
import * as path from 'path'

const BasicServer = require('realm-object-server').BasicServer
const path = require('path')
const server = new BasicServer()

server.start({
        console.log(`Does this get logged?`),
        dataPath: path.join(__dirname, '../data'),
        https-enable: true,
        https-key: '/etc/letsencrypt/live/{my domain in here}/privkey.pem',
        https-cert: '/etc/letsencrypt/live/{my domain in here}/cert.pem',
        https-address: 0.0.0.0,
        https-port: 9443
    })
    .then(() => {
        console.log(`Your server is started `, server.address)
    })    .then(() => {
        console.log(`Your server is started `, server.address)
    })
    .catch(err => {
        console.error(`There was an error starting your file`)
    })

当我启动 ros ( ros start) 时,控制台输出:

info: Realm Object Server version 2.0.4 is starting
info: Realm sync server started ([realm-core-4.0.2], [realm-sync-2.0.2]) service=sync
info: Directory holding persistent state: /home/ros_admin/bb/data/sync/user_data service=sync
info: Operating mode: master_with_no_slave service=sync
info: Listening on 127.0.0.1:36580 (sync protocol version 22) service=sync
info: sync-client: Connection[1]: Connected to endpoint '127.0.0.1:36580' (from '127.0.0.1:55292')
info: sync-client: Connection[2]: Connected to endpoint '127.0.0.1:36580' (from '127.0.0.1:55294')
info: sync-client: Connection[3]: Connected to endpoint '127.0.0.1:36580' (from '127.0.0.1:55296')
info: Starting auth provider 'password'
info: sync-client: Connection[4]: Connected to endpoint '127.0.0.1:36580' (from '127.0.0.1:55298')
info: 127.0.0.1 - GET /realms/files/%2F__admin HTTP/1.1 200 41 - 6.342 ms
info: 127.0.0.1 - GET /realms/files/%2F__revocation HTTP/1.1 200 46 - 1.071 ms
info: 127.0.0.1 - GET /realms/files/%2F__wildcardpermissions HTTP/1.1 200 55 - 1.201 ms
info: 127.0.0.1 - GET /realms/files/%2F__password HTTP/1.1 200 44 - 0.629 ms
info: Realm Object Server has started and is listening on http://0.0.0.0:9080
info: sync-client: Connection[5]: Connected to endpoint '0.0.0.0:9080' (from '127.0.0.1:33262')
info: sync-client: Connection[6]: Connected to endpoint '0.0.0.0:9080' (from '127.0.0.1:33266')

因为我没有看到任何控制台日志输出,所以我不得不假设我的配置没有被调用。这使我认为我将配置放置在错误的文件或位置中,或者我缺少一个额外的步骤。

任何人都可以建议吗?或者有没有人可以分享一个示例配置?

4

1 回答 1

0

您的配置对象格式错误。它应该是一个有效的 JSON 值。

  1. 第一console.log()行是无效的 JSON
  2. 您提供的带有连字符且未加引号的键名无效
  3. IP 值需要引用为字符串

命令行标志名称与您传递给的配置对象中的 javascript 等效名称不同server.start()

server.start({
        dataPath: path.join(__dirname, '../data'),
        https: true,
        httpsKeyPath: '/etc/letsencrypt/live/{my domain in here}/privkey.pem',
        httpsCertChainPath: '/etc/letsencrypt/live/{my domain in here}/cert.pem',
        httpsAddress: '0.0.0.0',
        httpsPort: 9443
    })

有关更多信息,请参阅此处的示例 Typescript 或 Javascript 配置

于 2017-12-06T19:01:06.320 回答