首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何为HTTPS连接配置Realm Object Server v2.0.4?

如何为HTTPS连接配置Realm Object Server v2.0.4?
EN

Stack Overflow用户
提问于 2017-10-24 14:14:41
回答 1查看 319关注 0票数 0

我已经在Ubuntu上部署了Realm Object Serverv2.0.4,还实现了LetsEncrypt。我可以使用新的Realm Studio连接-一切看起来都很好。

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

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

代码语言:javascript
复制
bb
└───src
│   │   index.ts

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

代码语言:javascript
复制
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)时,控制台输出:

代码语言:javascript
复制
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')

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

有人能给点建议吗?或者有人有可以分享的示例配置吗?

EN

回答 1

Stack Overflow用户

发布于 2017-12-07 03:01:06

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

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

的形式引用

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

代码语言: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
    })

请参阅example Typescript or Javascript config here for more information

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46903386

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档