需要在 HTTPS 上配置 Unleash 的帮助

问题描述 投票:0回答:1

我的服务器文件如下所示。

const unleash = require('unleash-server');
unleash
.start({
db: {
ssl: false,
host: 'localhost',
port: 5432,
database: 'unleash',
user: 'unleash_user',
password: 'password',
},
server: {
port: 8443,
},
})
.then((unleash) => {
console.log(
Unleash started on http://localhost:${unleash.app.get('port')},
);
});
I

这里有2个问题...

  1. 我得到的秘密为

    /vault/secrets/cert.pem and /vault/secrets/key.pem
    ...我想为8443端口(即HTTPS)配置这些秘密...有没有办法可以配置我的秘密

  2. 我需要在 2 个端口 HTTP 4242 和 HTTPS 8443 上运行我的应用程序有没有办法可以用它来配置 Unleash

我试着把 但似乎不起作用

node.js https unleash
1个回答
0
投票

我们建议为您设置一个终止 HTTPS 的代理,并向 Unleash 发送 HTTP 协议,就像 Express 文档(运行 Unleash 的 Web 框架)一样。 请参阅 http://expressjs.com/en/advanced/best-practice-security.html#use-tls

您可以使用像Nginx这样的代理服务器并配置SSL终止和监听多个端口。

以下是 Nginx 配置文件的示例:

# HTTP on 4242
server {
    listen 4242;
    server_name your_domain.com;

    # Any other settings...

    location / {
        proxy_pass http://localhost:4242;
        # Any other proxy settings...
    }
}

# HTTPS on 8443
server {
    listen 8443 ssl;
    server_name your_domain.com;

    ssl_certificate /path/to/your/cert.pem;
    ssl_certificate_key /path/to/your/key.pem;

    # Any other settings, like recommended SSL settings...

    location / {
        proxy_pass http://localhost:4242;
        # Any other proxy settings...
    }
}

如果您坚持让 Unleash 为您执行 HTTPS 终止,您需要使用

自行设置

这看起来像:

const https = require('node:https');
const fs = require('node:fs');
const options = {
  key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
  cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem')
};

let app = unleash.create();
https.createServer(options, app).listen(443);
© www.soinside.com 2019 - 2024. All rights reserved.