Tomcat – Lighttpd as tomcat proxy with static content serving

lighttpdPROXYstatic-contenttomcat

How can I configure Lighttpd to serve static content on specified URL address (eg. www.my-domain.com/static) from specified directory (e.g. /var/www/my-domain/static) ?

Rest of requests must be passed to tomcat container.

Actually I pass all requests to tomcat (see snippet below). I can't get it to work. So if it's not possible – NO is also answer for me. At least I will stop trying.

$HTTP["host"] =~ "www.my-domain.com" {
    proxy.server = ("" => (
                    "tomcat" => (
                            "host" => "127.0.0.1",
                            "port" => 8080,
                            "fix-redirects" => 1
                    )
            )
    )
}

Best Answer

You have to "disable" the proxy on static files (i.e. enable it only on other files):

$HTTP["host"] =~ "www.my-domain.com" {
    server.document-root = "/var/www/my-domain"
    $HTTP["url"] !~ "^/static" {
        proxy.server = ("" => ( "tomcat" => (
            "host" => "127.0.0.1",
            "port" => 8080,
            "fix-redirects" => 1
        ) ) )
    }
}

Also try debug.log-request-handling = "enable" and check error.log, also see http://redmine.lighttpd.net/projects/lighttpd/wiki/DebugVariables

Related Topic