1

My tomcat serves 2 sites

ROOT -> Main-site
/mobile -> dedicated mobile website 

I've configured lighttpd to serve as a proxy

$HTTP["host"] =~ "www.my-site.at" {
        proxy.server = ( "" => (
                        ( "host" => "127.0.0.1",
                          "port" => 8080
                        )
                ))
}

How can I tell lighttpd to use http://127.0.0.1:8080/mobile for m.my-site.at? Or do I have to configure a second tomcat and deploy the mobile site under ROOT?

Thank you

0

You could use url.rewrite-once to prefix all requests on m.my-site.at with /mobile:

$HTTP["host"] == "m.my-site.at" {
    url.rewrite-once = ( ".*" => "/mobile$0" )
    proxy.server = (...)
}

You might have to load mod_rewrite before mod_proxy to get this working.

The problem with rewrites like this is that the backend now sees a path that doesn't match the browsers view. The backend might try to emit paths prefixed with /mobile or do otherwise confusing stuff with relative paths. Some proxies might try to fix these paths in responses, but lighttpd does not (and you'll never catch all of them).

The real solution is to make the backend understand vhosts - i.e. handle requests different based on the hostname. If the backend cannot do that, you might want to run multiple instances, yes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.