代理请求
我尝试从节点接收安全的Web应用程序(HTTPS)代理请求(其内部应用程序)和IM不太清楚该怎么办呢...... 下面是我的代码工作当我尝试从一个非安全的应用程序(http)。代理请求
它只是剔除了页面名称,并用它在另一个应用程序。我阅读了文档,但仍不确定如何去做。我是否需要从我的应用程序中获取ssl信息才能正常工作?
var http = require('http');
var httpProxy = require('http-proxy');
var request = require('request');
var app = require('express.io')();
app.http().io();
//
// Create proxy server
//
var proxy = httpProxy.createProxyServer({target:'http://localhost:9000'}).listen(9085);
// Send the client html.
app.get('/', function(req, res) {
res.sendfile(__dirname + '/client1.html');
})
proxy.on('error', function (err, req, res) {
res.writeHead(500, {
'Content-Type': 'text/plain'
});
res.end('Something went wrong!');
});
app.all('/Domain/*', function(req, res) {
console.log(req.url);
if (req.url.indexOf("Page.do") > -1) {
// URL to Atlas
var otherAppURL = "http://myotherapp/pages/";
var temp = req.url.split("Page.do")[0].split("/");
var pageName = temp[temp.length - 1];;
app.io.broadcast('update', {
url: atlasURL + pageName + '.html'
});
};
// This doesnt work
//var url = "https://mysecureapp:9044" + req.url;
// This works
var url = "http://localhost:9080" + req.url;
req.pipe(request(url)).pipe(res);
})
app.listen(9000);
是的,您确实需要HTTPS连接的SSL证书。据该网站https://www.globalsign.com/en/ssl-information-center/what-is-an-ssl-certificate/:
The standard HTTP is changed to HTTPS, automatically telling the browser that the connection between the server and the browser must be secured using SSL.
这意味着,HTTPS连接,你需要有SSL保护的服务器。 对于在节点HTTPS连接,这个网站可以帮助你: http://gaboesquivel.com/blog/2014/nodejs-https-and-ssl-certificate-for-development/
感谢这....所以为了它的工作,我需要得到我的安全应用程序的证书,并以某种方式重用他们在我的程序... – blu10 2015-04-15 12:04:21
好吧,我可能会被误认,但此行没有任何意义,
req.pipe(request(url)).pipe(res);
由路由处理打时间中,REQ对象是准备 所以req.pipe
已经没有意义了。 请检查网址返回有效响应
request(url).pipe(res);
应该工作
HTTP/HTTPS是不是一个问题
该行我GOOGLE。即时通讯不知道它是如何工作的,但我试图做的是发回应用程序回应代理请求,以便它的行为正常。 它确实工作,但只有http。如果应用程序是安全的,它不会。 我只是你的建议尝试,并得到 – blu10 2015-04-15 11:58:48
stream.js:94 抛儿; //管道中未处理的流错误。 ^ 错误:在错误(原生) 在证书柴 自签名证书在TLSSocket。在TLSSocket._finishInit(_tls_wrap.js:458:8)处的TLSSocket.emit(events.js:104:17) (
这是不是真的清楚你想要做什么,请详细说明'IM尝试代理节点(其内部应用程序)中的安全Web应用程序(https)的请求并描述您的用例。另外,在你的代码中,“This does not work”并不是非常有用,究竟是什么问题? – 2015-04-11 21:56:40