Lighttpd proxying requests for Apache
*Not Complete
This is a brief
note I will update over time to reflect my current setup for serving
django with lighty proxying requests.
Benifits of proxying
The benefits of proxying web-requests has been well documented in
recent times. Lower over head for serving static files like html,
javascript, css and images. In my convoluted setup I am using lighttpd
to serve most of my static content which is far faster than using
apache with the inherent overhead of python and php and other modules
every time a file is requested.
Install the needed software sudo apt-get update sudo apt-get upgrade
sudo apt-get install apache2-mpm-worker apache2-threaded-dev lighttpd
libapache2-mod-python
Apache Configuration
I have configured apache to listen on port 81 and blocked it from
pubic access at the firewall because I will be using lighttpd to proxy
requests to apache . I also have disabled apache logging as it will be
handled by lighttpd.
<VirtualHost *:81>
ServerAdmin webmaster@example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /home/websites/example.com/www_root
<Location "/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE example.settings
PythonPath "['/home/websites/example.com']+sys.path"
PythonDebug Off
</Location>
</VirtualHost>
Lighttpd Configuration
server.modules += ( "mod_proxy","mod_rewrite", "mod_fastcgi", "mod_status","mod_cgi", "mod_redirect" )
$HTTP["host"] == "media.example.com" {
server.document-root = "/home/websites/example.com/media_root"
server.errorlog = "/home/websites/example.com/log/media.example.com.err.log"
accesslog.filename = "/home/websites/example.com/log/media.example.com.acc.log"
}
else $HTTP["host"] =~ "(^|\.)example\.com$" {
proxy.server = ( "" => ( ( "host" => "127.0.0.1","port" => 81 )))
server.errorlog = "/home/websites/example.com/log/www.example.com.err.log"
accesslog.filename = "/home/websites/example.com/log/www.daxroc.com.acc.log"
}
