从HTTPS端口代理

时间:2016-02-22 11:06:23

标签: node.js proxy http-proxy

我在NodeJS Server中代理HTTPS端口时遇到问题。我有两个我想要使用的localhost:后端工作在8080(HTTPS),而开发端口在4000上。

在我的代码中,我有以下内容:

 var app = express();

var apiProxy = httpProxy.createProxyServer({
    ws: true
});

 var REMOTE = {
    HTTP: 'https://localhost:8080',
    WS: 'ws://localhost:8080'
 };
    app.all("/api/*", function (req, res) {
        apiProxy.web(req, res, {target: REMOTE.HTTP,secure: true});
    });

app.all("/authentication/*", function (req, res) {
    apiProxy.web(req, res, {target: REMOTE.HTTP,secure: true});
});

app.all("/ws/info", function (req, res) {
    apiProxy.web(req, res, {target: REMOTE.HTTP,secure: true});
});

var server = app.listen(4000, function () {
    var host = server.address().address;
    var port = server.address().port;
    console.log('Example app listening at http://%s:%s', host, port);
});

哪个工作正常,直到我尝试从端口4000发出POST时。然后,我收到错误:

http-proxy/index.js:119
    throw err;
    ^

Error: self signed certificate
    at Error (native)
    at TLSSocket.<anonymous> (_tls_wrap.js:1003:38)
    at emitNone (events.js:67:13)
    at TLSSocket.emit (events.js:166:7)
    at TLSSocket._finishInit (_tls_wrap.js:570:8)

你对我做错了什么有任何想法吗?

0 个答案:

没有答案