好吧。我在express上有一个应用程序,它也使用Socket.io,通过HTTP工作得很好。然而,现在我不得不转向HTTPS。Nodejitsu为此提供了大量文档。他们建议使用node-http-proxy (https://github.com/nodejitsu/node-http-proxy)。很好!
来自HTTP的代码:
var server = http.createServer(app) // app is an Express instance
server.listen(config.port,config.hostip) // config.port is 80 for localhost and 3000 for Nodejitsu, config.hostip is 127.0.0.1 for localhost and 0.0.0.0 for Nodejitsu我得到了这个:
var server = http.createServer(app)
var options = {
https: {
key: fs.readFileSync(__dirname+"/ssl/privatekey.pem", 'utf8'),
cert: fs.readFileSync(__dirname+"/ssl/certificate.pem", 'utf8')
}
}
httpProxy.createServer(config.port, config.hostip, options).listen(3001,config.hostip)
var proxy = new httpProxy.HttpProxy({
target: {
host: config.hostip,
port: config.port
}
})
https.createServer(options.https, function (req, res) {
proxy.proxyRequest(req, res)
}).listen(3002,config.hostip)
server.listen(config.port,config.hostip)当我最终部署(部署期间没有错误)时,我访问页面并看到502错误套接字挂起。好吧,我可能做错了什么,所以我只是复制并粘贴了https://github.com/nodejitsu/node-http-proxy“从HTTPS到HTTP的代理”中的示例,以检查它是否工作。但它没有- 502错误。
不过它在我的本地主机上运行得很好。我也尝试过在没有node- HTTPS -proxy的情况下启动独立的https服务器,但是没有成功。请帮帮忙,我好几个星期都解决不了这个问题。
发布于 2013-05-16 16:47:17
我自己找到的。Nodejitsu默认提供SSL,只需通过HTTPS://访问您的站点。对于要应用SSL证书的自定义域,您需要订阅业务计划。
https://stackoverflow.com/questions/16566470
复制相似问题