Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js Docker-将本地主机HTTPS服务器从容器发布到主机_Node.js_Docker_Ssl_Https_Tls1.2 - Fatal编程技术网

Node.js Docker-将本地主机HTTPS服务器从容器发布到主机

Node.js Docker-将本地主机HTTPS服务器从容器发布到主机,node.js,docker,ssl,https,tls1.2,Node.js,Docker,Ssl,Https,Tls1.2,我已经构建了docker映像,以便在本地运行HTTPS Node.js服务器,并具有所有必需的TLS证书和良好的配置: ... var port = config.port || 9010, https; var tlsOptions = { pfx: fs.readFileSync('./tls/keystore.p12'), passphrase: ******, honorCipherOrder: true, secureOptions: constants

我已经构建了docker映像,以便在本地运行HTTPS Node.js服务器,并具有所有必需的TLS证书和良好的配置:

...
var port = config.port || 9010, https;
var tlsOptions = {
    pfx: fs.readFileSync('./tls/keystore.p12'),
    passphrase: ******,
    honorCipherOrder: true,
    secureOptions: constants.SSL_OP_NO_SSLv2 | constants.SSL_OP_NO_SSLv3    
};
try {
    https = require('https').Server(tlsOptions, app);
} catch (e) {
    console.error('Fail to start HTTPS server ' + e);
}
...
我已经使用curl在容器内部和主机中成功地测试了它

我现在要发表https://localhost:9010 将其绑定到的容器的https://localhost:9010 docker的主人。我使用了以下命令:

docker container run --publish 9010:9010 --detach --name https_server_container https_server:1.0
当我跑步的时候https://localhost:9010from docker的主机,我的本地计算机,我收到此错误:

curl: (35) schannel: failed to receive handshake, SSL/TLS connection failed
我试着跟着docker doc但什么也没做

要在容器中正确发布https节点服务器,我应该遵循哪些步骤


谢谢

在我看来,docker命令有一些输入错误:

docker容器运行-发布9010:9010-分离-名称https\u服务器\u容器https\u服务器:1.0 您需要在9010和-detach之间留出空间,正如我将docker容器中运行的Node.js服务器的服务器主机从127.0.0.1更改为0.0.0.0所示


通过这种方式,我现在可以通过从docker主机访问docker容器中的服务器。

容器内的服务需要侦听0.0.0.0所有接口,否则无法从容器外访问。您的设置是否正确,还是仅在容器专用本地主机上侦听?您好,David,非常感谢您的评论。它解决了我的问题!我的Node.js服务器是在127.0.0.1上监听的,而不是在0.0.0.0上监听的,我在0.0.0.0上进行了更改,现在可以从docker的主机上访问它。您好,谢谢您的回答,但问题中的输入错误。我已经执行了9010到-detach之间的命令
...
https.listen(port, '0.0.0.0', function() {
    ...
});