lighttpd forum lighty > Config for Lighty as proxy for Apache

Posted by Angelo Mandato
on 18.08.2007 02:16
I started using Lighty 3 days ago.  After doing some performance testing 
I've decided to switch to Lightly for handling static files and 
rewrite/redirects.  I plan to continue to use Apache dynamic PHP 
scripts.

I'm running Lighty on port 80 and Apache on port 81.  Using the 
techniques documented for mod_proxy, I ran into a problem where the 
directory index requests were not being passed onto Apache for index.php 
files.  It took me a little while but after some experimenting I wrote 
the following code.

	# .php files
	proxy.server               = ( ".php" =>
		(
			(
				"host" => "127.0.0.1",
				"port" => 81
			)
		)
	)
	# / requests that may or may not have a query string
	$HTTP["url"] =~ "/(\?.*)?$" {
		proxy.server               = ( "" =>
			(
				(
					"host" => "127.0.0.1",
					"port" => 81
				)
			)
		)
	}

The first block is commonly what you would find in documentation.  The 
second block uses a regular expression to compare the requested GET 
(Lightly calls this the url).  If the GET request ends with a / or ends 
with a /? plus other characters, it is presumed the request is for a 
directory index and will use the proxy to pass the request on to Apache 
running on port 81.

I hope this information is useful to others.
Posted by Olaf van der Spek
on 20.08.2007 20:05
Angelo Mandato wrote:
> rewrite/redirects.  I plan to continue to use Apache dynamic PHP 
> scripts.

Why? Wouldn't it be much easier to use Lighttpd for that too?