【问题标题】:Cloudflare + Reverse Proxy - Error 1000Cloudflare + 反向代理 - 错误 1000
【发布时间】:2016-11-10 12:06:56
【问题描述】:

由于 SEO,我设置了一个可以正常工作的反向代理:

设置如下:

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

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

3) 访问http://www.example.com/blog 的访问者从http://blog.example.com 获取内容。

这很好用,并且在 1) 我也有代理与流行的 nodejitsu htt-proxy 和 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

发生了什么,我应该如何着手解决这个问题?

【问题讨论】:

    标签: node.js wordpress reverse-proxy cloudflare


    【解决方案1】:

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

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

    【讨论】:

    • 嗨,mjsa,关于“理想情况下,您的 Node.js 代理应该直接指向源 Web 服务器,而不是通过 CloudFlare 返回。”您能否更具体地说明我应该如何通过更改 node.js 反向代理脚本来做到这一点?
    • 继续并更改托管脚本的服务器上的 /etc/hosts 文件,使这些域直接指向源服务器。否则,您可以使用原始服务器的 IP 地址而不是脚本中的域名。
    猜你喜欢
    • 2016-04-11
    • 1970-01-01
    • 2020-03-24
    • 1970-01-01
    • 2012-12-07
    • 2016-04-28
    • 1970-01-01
    • 1970-01-01
    • 2020-01-06
    相关资源
    最近更新 更多