Lighttpd proxy module – use with hostname

hostnamelighttpdPROXY

I have to proxy a site which is hosted on an external webspace through my lighty on example.org.
My config so far:

$HTTP["url"] =~ "^/webmail" {
    proxy.server =  ("/webmail/" => (
        # this entry should link to example2.org
        ("host" => "1.2.3.4", "port" => 80)
    ))
}

The webspace provider has configured my domain as vhost. So if i access http://1.2.3.4/webmail/ lighttpd will only deliver the main site of the
webspace provider which says "Site example.org was not found on our server."

Any suggestions how i have to configure lighty to proxy sites that are only hosted as vhost (and do not have an ip on their own)?

Best Answer

I believe this can be fixed with mod_setenv:

$HTTP["url"] =~ "^/webmail" {
    # add host header
    setenv.add-request-header ( "Host" => "example2.org" )

    proxy.server =  ("/webmail/" => (
        # this entry should link to example2.org
        ("host" => "1.2.3.4", "port" => 80)
    ))
}
Related Topic