librelist archives

« back to archive

LighttpdCGIRootFix not working as expected?

LighttpdCGIRootFix not working as expected?

From:
Michael Elsdörfer
Date:
2012-01-29 @ 16:54
I just had some trouble getting an app to work on lighttpd/1.4.19 using
FastCGI (Flask 0.8).

Initially, url_for() returned urls with the /msite.fcgi/ prefix. I'm 
familiar with this problem (the FORCE_SCRIPT_NAME setting in Django) so 
I turned on the LighttpdCGIRootFix middleware, assuming is is intended 
to address exactly that problem. After this, all requests returned 404s, 
with the url being routed something like /mysite.fcgi/foo.

The reason is that the middleware prepends SCRIPT_NAME to
PATH_INFO, before clearing out SCRIPT_NAME.

So without the middleware, I have:

path_info=/foo
script_name=/mysite.fcgi

and with it:

path_info=/mysite.fcgi/foo
script_name=

So I wrote my own middlware, settting script_name to an empty string and 
leaving path_info untouched, like I would usually expect to do, and 
there you go, it works.

Am I misunderstanding the purpose of LighttpdCGIRootFix?

Michael