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:
Is it possible?
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" ), ) }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With