2

我正在使用 lighttpd 和运行在后面的 tomcat。我希望 lighttpd 处理所有静态文件,如图像/css。这是我的配置:

$HTTP["host"] =~ "www.example.com" {
    alias.url = ( "/images_deal/" => "/home/deal/projects/deal/images/" )   
    alias.url += ( "/statics_deal/" => "/home/deal/workspace2/dolo/statics/" )  
    proxy.server = ( "" =>                 
        ( "tomcat" =>
            (
                "host" => "127.0.0.1",
                "port" => 8080,
                "fix-redirects" => 1
             )
        )
    )
}

server.modules = (  "mod_access",  "mod_alias",  "mod_redirect",  "mod_rewrite",)

问题是我无法访问像http://www.example.com/images_deal/img.png这样的 url 上的图像

我编写了一个新的 lighthttpd 配置,可以访问静态文件,但现在的问题是我无法直接访问我的 tomcat 上下文,我的意思是:将所有请求 www.example.com 重写为 www.example.com/dolo/ 之前将其传递给 tomcat(因为 tomcat 有多个上下文。新配置

    alias.url = (
        "/images_deal" => "/home/deal/projects/deal/images/",
        "/statics_deal/"      => "/home/deal/workspace2/dolo/statics/",
    )
  $HTTP["url"] !~ "^(/statics_deal/|/images_deal/)" {
   url.rewrite-once = ( "^/(.*)" => "/dolo/$1", )      
   proxy.server = ( "" =>
                 ( "tomcat" =>
                   (
                     "host" => "127.0.0.1",
                     "port" => 8080,
                     "fix-redirects" => 1
                   )
                 )
              )
  }
}
4

0 回答 0