【发布时间】: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