繁体   English   中英

节点http-代理:将流量转发到外部https站点-崩溃

[英]Node http-proxy: forward traffic to external https site - crashes

我想将REST请求从我的前端wepp应用程序传输到外部Jira服务器上的API。

为此,我使用节点http-proxy ,对于使用http的Jira服务器而言,这是可以的。

但是现在我想为https创建一个单独的服务器。

因此, 对该示例进行som更改后,我现在有了:

var path  = require('path'),
    fs    = require('fs'),
    httpProxy = require('http-proxy'),
    certFolder = '/my/cert/folder';

//
// Create the HTTPS proxy server listening on port 8002
//
httpProxy.createServer({

  //(placeholder address)
  target: {
    host: 'https://ext.jiraserver.com',
    port: 443
  },

  // letsencrypt cert
  ssl: {
    key: fs.readFileSync(path.join(certFolder, 'privkey.pem'), 'utf8'),
    cert: fs.readFileSync(path.join(certFolder, 'fullchain.pem'), 'utf8')
  },

  secure: true
}).listen(8002);

console.log('https proxy server started  on port  8002');

但是,当我向服务器https://my.domain.com:8002发出请求时,它使服务器崩溃并显示错误消息:

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

错误:getaddrinfo ENOTFOUND https://ext.jiraserver.com https://ext.jiraserver.com:443在errnoException(dns.js:28:10)在GetAddrInfoReqWrap.onlookup处[作为完整的](dns.js:76: 26)

我似乎无法正常工作...服务器处于联机状态,并且地址正确,因此我不知道出了什么问题。

是我的代码有误还是我该怎么做才能使它正常工作?

谢谢!

不要在DNS主机定义中包含https://

host: 'ext.jiraserver.com',

该错误消息告诉您这是DNS解决问题。 您正在尝试查找https://ext.jiraserver.com的DNS,包括https

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM