2016-07-08 83 views
2

因为SEO的我已经安装工作正常的反向代理:的CloudFlare +反向代理 - 错误1000

的设置如下:

1)http://www.example.com(在Heroku的托管的node.js)

2)http://blog.example.com(WordPress的托管在godaddy的)

3) v正在访问http://www.example.com/bloghttp://blog.example.com获取内容。

这工作得很好,并在1)我也有代理与流行nodejitsu HTT代理和httpProxyRules模块工作:

// Set up proxy rules instance 
var proxyRules = new httpProxyRules({ 
    rules: { 
     '.*/blog': 'https://blog.example.com', // Rule (1) 
    }, 
    default: 'https://www.example.com' // default target 
}); 

// Create reverse proxy instance 
var proxy = httpProxy.createProxy(); 

// Create http server that leverages reverse proxy instance 
// and proxy rules to proxy requests to different targets 
http.createServer(function(req, res) { 
    // a match method is exposed on the proxy rules instance 
    // to test a request to see if it matches against one of the specified rules 
    var target = proxyRules.match(req); 
    if (target) { 
     return proxy.web(req, res, { 
     target: target, 
     changeOrigin: true, 
     }); 
    } 

    res.writeHead(500, { 'Content-Type': 'text/plain' }); 
    res.end('The request url and path did not match any of the listed rules!'); 

}).listen(6010); 

然后我试图加入CloudFlare的SSL证书,所以我可以有HTTPS。我知道Cloudflare本身就是一个反向代理。因此,总共我会在我的设置中使用3个反向代理,1),2)(均使用Cloudflare的反向代理)和3)(我的自定义反向代理)。

另外,1)和2)都可以正常使用https。但是,3)破产。

为3),我不断收到错误:

错误1000 - DNS指向禁止IP

这是怎么回事,我该如何着手解决这个问题?

回答

3

因此,您正在将CloudFlare DNS指向您区域文件中的另一个代理。由于CloudFlare也是一个反向代理,因此enabling a proxy on a record may create a cyclic loop

为了解决这个问题,你的Node.js代理应该直接指向原始Web服务器,而不是通过CloudFlare返回。如果您不想更新您的脚本,则可以在服务器上通过更新执行代理的Web服务器上的主机文件来添加直接路由到您的源。

+0

嗨mjsa,关于“你的Node.js代理应该直接指向原始web服务器,而不是通过CloudFlare回去。”你能更具体地说我应该怎么做,通过改变node.js反向代理脚本? – user1347271

+0

继续并在托管脚本的服务器上更改/ etc/hosts文件,以便这些域直接指向原始服务器。否则,您可以将IP地址用于原始服务器,而不是脚本中的域名。 – mjsa