【问题标题】:Error when proxying to blog sub domain from node.js application从 node.js 应用程序代理到博客子域时出错
【发布时间】:2015-06-20 02:56:38
【问题描述】:

我在 www.example.com 上的 heroku 上托管了一个 nodejs 应用程序 然后我有一个 wordpress 博客,目前在一个子域上 - blog.example.com

我在 express 中有一个路线设置:

(使用express-http-proxy

var proxy = require('express-http-proxy');

app.use('/blog', proxy('blog.example.com', {
    forwardPath: function(req, res) {
        return require('url').parse(req.url).path;
    }
}));

这很有效,因为我可以在 www.example.com/blog 上看到博客“主页” - 它正确代理并且对 blog.example.com 透明

但是,如果我访问那里的任何博客文章,它会因 500 错误而崩溃

[error] [client (ipAddressHere)] 由于可能的配置错误,请求超出了 10 个内部重定向的限制。如有必要,使用“LimitInternalRecursion”增加限制。使用'LogLevel debug'获取回溯。,referer:http://www.example.com/blog/

我怀疑这与我的 htaccess 有关 - 但不知道是什么?

我的 htaccess 是:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>

# END WordPress

【问题讨论】:

    标签: node.js wordpress .htaccess express proxy


    【解决方案1】:

    从我的 htaccess 中删除 /blog 以使其成为:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress
    

    现在可以使用了 从我的节点应用程序 /blog 到 wordpress 博客的透明代理!

    【讨论】:

      猜你喜欢
      • 2013-12-13
      • 1970-01-01
      • 2014-01-12
      • 2017-02-06
      • 1970-01-01
      • 1970-01-01
      • 2012-10-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多