Sample Code
var http = require('http'),
httpProxy = require('http-proxy');
//
// Create a proxy server with latency
//
var proxy = httpProxy.createProxyServer();
//
// Create your server that makes an operation that waits a while
// and then proxies the request
//
http.createServer(function (req, res) {
// This simulates an operation that takes 500ms to execute
setTimeout(function () {
proxy.web(req, res, {
target: 'https://www.google.co.kr'
});
}, 500);
}).listen(8008);
Error Stack
Error: Hostname/IP doesn't match certificate's altnames: "IP: xxx.xxx.xxx.xxx is not in the cert's list: "
at Object.checkServerIdentity (tls.js:203:15)
at TLSSocket.
at emitNone (events.js:86:13)
at TLSSocket.emit (events.js:185:7)
at TLSSocket._finishInit (_tls_wrap.js:580:8)
at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:412:38)
try adding the changeOrigin: true
http.createServer(function (req, res) {
setTimeout(function () {
proxy.web(req, res, {
target: 'https://www.google.co.kr',
changeOrigin: true
});
}, 500);
}).listen(8008);
Thanks! It was helpful. I tested by your advice. and it was succeeded.
Most helpful comment
try adding the
changeOrigin: true