如何为 HTTPS 连接配置 Realm 对象服务器 v2.0.4



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

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

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

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')

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

谁能建议? 或者是否有人有可以共享的示例配置?

您的配置对象格式不正确。它应该是一个有效的 JSON 值。

  1. 第一个console.log()行是无效的 JSON
  2. 您提供的包含连字符且未加引号的键名称无效
  3. IP 值需要以字符串形式引用

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

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 配置。

相关内容

  • 没有找到相关文章

最新更新