use*_*271 2 wordpress reverse-proxy node.js cloudflare
因为SEO我设置了一个工作正常的反向代理:
设置如下:
1) http://www.example.com(node.js托管在heroku)
2) http://blog.example.com(在godaddy托管的wordpress)
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);
Run Code Online (Sandbox Code Playgroud)
然后我尝试添加Cloudflare SSL证书,以便我可以使用https.我知道Cloudflare本身就是一个反向代理.总的来说,我的设置中有3个反向代理,1),2)(两者都使用Cloudflare的反向代理)和3)(我的自定义反向代理).
另外,1)和2)都可以正常使用https.但是,3)破了.
对于3),我一直收到错误:
错误1000 - DNS指向禁止的IP
发生了什么,我该如何解决这个问题?
因此,您将CloudFlare DNS指向区域文件中的另一个代理.由于CloudFlare也是反向代理,因此在记录上启用代理可能会创建循环循环.
为了解决这个问题,您的Node.js代理应该直接指向原始Web服务器,而不是通过CloudFlare返回.如果您不想更新脚本,则可以通过更新执行代理的Web服务器上的hosts文件,在服务器上添加直接路由到您的源.
| 归档时间: |
|
| 查看次数: |
1543 次 |
| 最近记录: |