节点http-proxy:将stream量转发到外部https站点 – 崩溃
我想从我的前端wepp应用程序将REST请求传输到外部Jira服务器上的API。
为此,我正在使用节点http-proxy ,这对于Jira服务器来说是可以使用的。
但是现在我想为https创build一个单独的服务器。
所以使这个例子改变我现在有这样的:
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 [as oncomplete](dns.js:76: 26)
我似乎无法得到它的工作…服务器在线和地址是正确的,所以我不知道什么是错的。
是我的代码是错的,或者我能做些什么才能使这个工作?
谢谢!
不要在DNS主机定义中包含https://
。
host: 'ext.jiraserver.com',
错误消息告诉你,这是一个DNS解决问题。 您正在尝试查找包含https
的https://ext.jiraserver.com
的DNS。