lighttpd configuration to proxy/rewrite from one domain to another
lighttpd, mod-proxy, mod-rewrite
Solution
Your need is known by lighttpd developers from several years.
It is answered by a workaround or new feature depending on the version.
Lighttpd 1.4
A workaround is explained in the bugtracker : bug #164
$HTTP["url"] =~ "(^/path1/)" {
proxy.server = ( "" => ("" => ( "host" => "127.0.0.1", "port" => 81 )))
}
$SERVER["socket"] == ":81" {
url.rewrite-once = ( "^/path1/(.*)$" => "/$1" )
proxy.server = ( "" => ( "" => ( "host" => "server2.com", "port" => 80 )))
}
Lighttpd 1.5
They added this feature with this command (official documentation) :
proxy-core.rewrite-request : rewrite request headers or request uri.
$HTTP["url"] =~ "^/path1" {
proxy-co...
proxy-core.rewrite-request = (
"_uri" => ( "^/path1/?(.*)" => "/$1" ),
"Host" => ( ".*" => "server2.com" ),
)
}
Problem
i need to setup proxy/rewrite on lighttpd! i have server1, which serves via http 2 different web app paths: ``` * http://server1/path1 * http://server1/path2 ``` also, i have lighttpd server in front of server1 i want to setup rewriting and/or proxing on lighttpd, so that each of the 2 paths would be served as root path on different domains: ``` * requests to http://server2.com/* are proxied/rewrited to http://server1/path1/* * requests to http://server3.com/* are proxied/rewrited to http://server1/path2/* ``` important: - server2.com and server3.com can access server1 only via http - redirects are not the option, users of server2.com & server3.com shouldn't not know that the actual web apps are served from different paths of server1. Is it possible?