Using MoinMoin with lighttpd for a root wiki

(version française)

MoinMoin uses the PATH_INFO1 CGI environment variable to know the name of the current page being requested (via FastCGI or SCGI). For a root wiki, the PATH_INFO sent by lighttpd 1.4.19 thru FLUP is incorrect2.

This will affect your wiki as follows:

The option fix-root-scriptname, available since lighttpd 1.4.23, fixes this issue, e.g.:

    fastcgi.server = ( "/" =>
      ((
        "host" => "127.0.0.1",
        "port" => 45999,
        "check-local" => "disable",
        "fix-root-scriptname" => "enable",
      ))
    )

This option is available both for SCGI and FastCGI.

Thanks to Thomas Waldmann for suggesting this fix.

  1. Download the fixers.py script from http://dev.pocoo.org/projects/werkzeug/browser/werkzeug/contrib/fixers.py.

  2. Copy fixers.py in the directory of moin_flup_wsgi.py.

  3. Apply the following patch to moin_flup_wsgi.py:

    --- moin_flup_wsgi.py 2009-01-07 00:26:55.000000000 +0000
    +++ moin_flup_wsgi.py.revu 2009-03-02 19:28:19.000000000 +0000
    @@ -41,6 +41,7 @@
    
     from flup.server.fcgi import WSGIServer
     from MoinMoin.server.server_wsgi import moinmoinApp, WsgiConfig
    +from fixers import LighttpdCGIRootFix
    
     class Config(WsgiConfig):
         pass
    @@ -48,7 +49,7 @@
     config = Config()
    
     if __name__ == '__main__':
    - server = WSGIServer(moinmoinApp, bindAddress=unixSocketPath)
    + server = WSGIServer(LighttpdCGIRootFix(moinmoinApp), bindAddress=unixSocketPath)
         server.run()
         os.unlink(unixSocketPath)
  4. Compile the 2 scripts with py_compilefiles :

    py_compilefiles *.py
  5. Restart MoinMoin.

The quick and dirty solution: patching MoinMoin 1.9

The following patch will fix the values provided by lighttpd. It will only fix the FastCGI interface (fixing SCGI should be similar).

Apply the following patch to MoinMoin/support/flup/server/fcgi_base.py:

--- fcgi_base.py.ori    2010-03-15 18:26:22.000000000 +0000
+++ fcgi_base.py        2010-03-15 18:23:25.000000000 +0000
@@ -1075,6 +1075,10 @@
 
         # Mostly taken from example CGI gateway.
         environ = req.params
+
+        environ["PATH_INFO"] = environ["SCRIPT_NAME"] + environ["PATH_INFO"]
+        environ["SCRIPT_NAME"] = ''
+
         environ.update(self.environ)
 
         environ['wsgi.version'] = (1,0)

The quick and dirty solution: patching MoinMoin 1.8

The following patch will fix the values provided by lighttpd. It will only work for this precise problem.

--- MoinMoin/request/__init__.py.original      2009-02-17 23:04:03.000000000 +0000
+++ MoinMoin/request/__init__.py       2009-02-17 23:04:52.000000000 +0000
@@ -414,8 +414,8 @@
         self.server_name = env.get('SERVER_NAME', self.server_name)
         self.server_port = env.get('SERVER_PORT', self.server_port)
         self.saved_cookie = env.get('HTTP_COOKIE', '')
-        self.script_name = env.get('SCRIPT_NAME', '')
-        self.path_info = env.get('PATH_INFO', '')
+        self.script_name = ''
+        self.path_info = env.get('SCRIPT_NAME', '') + env.get('PATH_INFO', '')
         self.query_string = env.get('QUERY_STRING', '')
         self.request_method = env.get('REQUEST_METHOD', None)
         self.remote_addr = env.get('REMOTE_ADDR', '')

Feedback

You can send me your comments and suggestions to <jean DASH philippe DOT guerard AT tigreraye DOT org>.


This page is licensed under the Creative Commons Attribution 2.0 License.