3

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)?

gorootde
  • 226
  • 1
  • 3
  • 9

2 Answers2

1

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)
    ))
}
Vladimir Blaskov
  • 6,183
  • 1
  • 27
  • 22
  • unfortunately that doesn't work. add-request-header just ADDs a header, so the request will contain "example.org, example2.org" as host header. There's an patch that enables set-request-header. That's not an option, I want to continue using the maintainers lighty version. Otherwise I'll have to patch my build by hand every time a security update gets released. – gorootde Sep 21 '11 at 17:30
  • Which version of Lighty do you use? – Vladimir Blaskov Sep 21 '11 at 20:19
  • I'am using Version 1.4.29 – gorootde Oct 04 '11 at 11:33
0

You need to get your hosting provider to support the X-Forwarded-Host header. Maybe it already works, try it. This can be readily added with built-in lighttpd capabilities.

proxy.forwarded = ( "host" => 1 )

enables it in your proxying server.

Zdenek
  • 240
  • 1
  • 4