【问题标题】:Proxying a sub folder using Lighttpd mod_proxy使用 Lighttpd mod_proxy 代理子文件夹
【发布时间】:2012-09-29 05:46:21
【问题描述】:

我无法让 mod_proxy 正确地将流量转发到在同一台机器上为预定义子文件夹运行的不同网络服务器。理想情况下,domain.com/docs 应该转发到 127.0.0.1:3000,所有其他流量都应该保留在 domain.com 上。这里的重写规则适用于在 domain.com 上运行的 wordpress 安装:

$HTTP["host"] =~ "(^|\.)domain\.com" {
 $HTTP["url"] =~ "^/docs" {
  proxy.server  = ( "" => (( "host" => "127.0.0.1", "port" => 3000 )))
 } 
 $HTTP["url"] !~ "^/docs/(.*)" {
  url.rewrite = (
   "^/(.*)\.(.+)$" => "$0",
   "^/wp/(.*)$" => "$0",
   "^/(.+)/?$" => "/index.php/$1"
  )
  server.document-root = "/mnt/webroot/html"
 }
}

我一直在反对这个问题,所以欢迎提出任何建议。

【问题讨论】:

    标签: lighttpd mod-proxy


    【解决方案1】:

    我最终找出了导致它无法像我预期的那样工作的问题。

    lighttpd 的 rewrite mod 的工作方式是在评估 $HTTP["url"] 条件之前评估所有 url.rewrite 命令,这意味着放置在 $HTTP["url"] 条件中的任何 url.rewrite 命令都会没有效果。

    由于此限制,我无法为我正在寻找的实现找到一个好的解决方案,而是最终将一些重写向下游推送到我正在代理流量的另一台服务器(本例中为节点)到。

    这在 lighttpd 的 ModRewrite 文档中以这行粗略地提及:

    NOTE: url rewriting does not work within a $HTTP["url"] conditional.
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-11-19
      • 2011-01-14
      • 2018-07-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-26
      • 1970-01-01
      相关资源
      最近更新 更多