use*_*084 5 ssl https node.js openshift
在OpenShift网站上:https://help.openshift.com/hc/en-us/articles/202535440-How-do-I-get-SSL-for-my-domains- ,它说明
You can always take advantage of our *.rhcloud.com wildcard certificate in order
to securely connect to any application via it's original, OpenShift-provided
hostname URL.
Run Code Online (Sandbox Code Playgroud)
但是,Node的HTTPS服务器需要证书和私钥的文件路径才能使用HTTPS:
var privateKey = fs.readFileSync('sslcert/server.key', 'utf8');
var certificate = fs.readFileSync('sslcert/server.crt', 'utf8');
var credentials = {key: privateKey, cert: certificate};
var express = require('express');
var app = express();
var httpsServer = https.createServer(credentials, app);
httpsServer.listen(443);
Run Code Online (Sandbox Code Playgroud)
OpenShift环境变量(https://www.openshift.com/developers/openshift-environment-variables)似乎都与SSL证书无关,除上述链接外,文档没有提及它,实际使用它的技术信息.
如何访问OpenShift Node.js gear/cartridge上的privateKey和证书文件?
use*_*084 10
事实证明,所有SSL证书都是在OpenShift路由器到达齿轮/磁带之前由其处理的.根本不需要设置HttpsServer,正常的HttpServer监听端口8080将透明地接收HTTP和HTTPS流量.
无论您使用的是自定义证书还是通配符证书都是如此,这非常漂亮.
| 归档时间: |
|
| 查看次数: |
2613 次 |
| 最近记录: |