2016-07-08 82 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