On Sat, 2009-07-04 at 02:13:04 -0700, pepijn wrote:
> "actually pointed to better solutions... thanks"
> Can you share your solution please?
> I am also trying to run Pylons with Lighttpd...

Maybe he means mod_proxy?  At least for me it was a simpler solution.
Mainly because it worked right from the beginning.

To use lighttpd as a reverse proxy you need to uncomment/add mod_proxy
in server.modules.  Then somewhere in your config file below put
something like this:

  $HTTP["host"] =~ "^foobar\.example\.org$" {
      $HTTP["url"] =~ "^/(script|style)/" {
          server.document-root = "/path/to/static/docs"
      }
      $HTTP["url"] !~ "^/(script|style)/" {
          proxy.server = ("" => ( ("host" => "127.0.0.1", "port" => 5000) ) )
      }
  }

This is the rule for single domain (but you can use it any way you like by
changing regexp), which contains two URL rules.  The first one is for static
files, the second one is for everything *except* static files and points to
your WSGI server (or servers; there can be more than one for load balancing; if
you're interested, read the docs), which can be paste.httpserver or whatever
you prefer (CherryPy's WSGI server, Spawning, etc).

There are various ways how to start and manage your WSGI server.  I've
written simple init scripts, since I don't have any special requirements
for my personal stuff, but people here several times were discussing
about supervisor, monit and some other names I don't recall at the
moment.  You can look into the mailing list archives for deployment
discussions.

Also to avoid serving static files via Pylons while in production mode,
modify the last two lines before return in config/middleware.py:

  if config['debug']:
      static_app = StaticURLParser(config['pylons.paths']['static_files'])
      app = Cascade([static_app, app])

Oh, and if you need an IP of the client connecting to your server, you
can get it from environ['HTTP_X_FORWARDED_FOR'].  REMOTE_ADDR will
always contain an IP of computer lighttpd is running on (if it's the
same for WSGI server, it'll be 127.0.0.1).

HTH,
-- 
Audrius Kažukauskas

Attachment: pgpBxnsBqY1r2.pgp
Description: PGP signature

Reply via email to