我遇到问题,让https使用节点http-proxy。
我使用节点http-server
创建了一个服务器forever /usr/local/lib/node_modules/http-server/bin/http-server /home/blah/public_html/ -p 5000 -S -C /myencrypt/blah.com/cert.pem -K /myencrypt/blah.com/privkey.pem
如果我去https://blah.com:5000,Certs工作正常。
如果我去blah.com,我会收到以下错误
Error: unable to verify the first certificate
at TLSSocket.<anonymous> (_tls_wrap.js:1088:38)
at emitNone (events.js:86:13)
at TLSSocket.emit (events.js:188:7)
at TLSSocket._finishInit (_tls_wrap.js:610:8)
at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:440:38)
我在这里缺少什么?
var fs = require('fs');
var http = require('http');
var https = require('https');
var httpProxy = require('http-proxy');
var proxy = httpProxy.createProxy();
var options = {
'blah.com':{
target:'https://blah.com:5000',
ssl:{
key:fs.readFileSync('/myencrypt/blah.com/privkey.pem', 'utf8'),
cert:fs.readFileSync('/myencrypt/blah.com/cert.pem', 'utf8')
}
}
}
http.createServer(function(req, res) {
proxy.web(req, res, {
target: options[req.headers.host].target,
ssl : options[req.headers.host].ssl
});
}).listen(80);
答案 0 :(得分:0)
我决定使用redbird
来解决我的问题var redbird = require('redbird')({
port: 80,
secure:false,
ssl: {
port:443,
key: "/myencrypt/blah.com/privkey.pem",
cert: "/myencrypt/blah.com/cert.pem",
}
});
redbird.register('blah.com', 'https://blah.com:5000', {
ssl: {
key: "/myencrypt/blah.com/privkey.pem",
cert: "/myencrypt/blah.com/cert.pem",
}
});