Lighttpd as reverse proxy

June 18, 2008
Author
Vadim Tkachenko
Share this Post:

We often recommend to set lighttpd in front of apache to handle http requests (more about https://www.percona.com/blog/speedup-your-lamp-stack-with-lighttpd/ ) , redirect dynamic requests to apache and handle static files by itself. I just gathered step-by-step instruction how to do that in 10 minutes, as it may be not so obvious.

  • Of course you need lighttpd by itself, it’s available on http://www.lighttpd.net/download
  • You may want pcre-devel packet, which allows to use regular expressions in lighttpd.conf. For CentOS boxes we just run
  • Take sample config file

    and put to
  • Create directory to store log files, e.g.

    . Despite it looks simple, lighttpd may just die trying to create files in non-existing directory.
  • Set

    to point to actual directory with web documents
  • Uncomment next lines in lighttpd.conf

    mod_status is useful to show additional information from lighttpd
    mod_auth to protect mod_status from unauthorized access 🙂
    and mod_proxy is proxy by itself
  • to enable status uncomment or add

    to lighttpd.conf
  • to protect access to /server-status put next lines to lighttpd.conf

    It enables htpasswd file based authentication, you can just manage this file with htpasswd utility from apache.
  • and finally make changes related to proxy
    1. Move apache from 80 port to another, e.g. 8080 or pick your own.
    You need to change

    and

    directives in httpd.cong
    and meantime set

    , as we want apache only handling dynamic pages.
    2. put next lines to lighttpd.conf:

    This actually directs lighttpd to redirect all requests, besides one ending

    (you can add your own static pages), to apache listening on 8080 port
  • Final step to add lighttpd to list of services (actual only for RedHat / CentOS)

    fix path

    and add script to autostart

That’s all. For complex apache setups and VirtualHosts it may be trickier, but work just fine for simple cases.

Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Far
Enough.

Said no pioneer ever.
MySQL, PostgreSQL, InnoDB, MariaDB, MongoDB and Kubernetes are trademarks for their respective owners.
© 2026 Percona All Rights Reserved