如何访问OpenShift通配符SSL证书和私钥

在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. 

但是,Node的HTTPS服务器需要指向证书和私钥的文件path才能使用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); 

似乎没有一个OpenShift环境variables( https://www.openshift.com/developers/openshift-environment-variables )似乎与SSL证书相关,除了上面的链接,文档没有提及它,它没有提供技术信息在实际使用中。

如何访问OpenShift Node.js齿轮/盒式磁带上的私钥和证书文件?

事实certificate,所有的SSL证书都是由OpenShift路由器在到达设备/盒之前处理的。 根本不需要设置HttpsServer,正常的HttpServer监听端口8080将透明地接收HTTP和HTTPSstream量。

无论您是使用自定义证书还是通配符证书,这都是非常好的。

NodeJs Express应用场景详见OpenShift https答案 。 综上所述,使用由openshift的代理提供给您的nodejs web服务器的请求头中的X-Forwarded-Proto头的值来确定答复是否应该将客户端redirect到https或客户端已经在https上请求。