Using MoinMoin with lighttpd for a root wiki
MoinMoin uses the PATH_INFO
1 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:
When you click on a first link of the wiki (
LinkOne
), this link is shown in the URL bar, but the page itself is not shown.When you click on a second link (
SecondLink
), this new page is shown, but the URL in the URL bar now contains both links (http://myweb.example.org/LinkOne/SecondLink
).
Recommended fix: upgrade lighttpd (MoinMoin 1.8 and 1.9)
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.
Recommended fix: the Werkzeug Team fixers.py script (MoinMoin 1.8)
Thanks to Thomas Waldmann for suggesting this fix.
Download the
fixers.py
script from https://github.com/pallets/werkzeug/blob/master/werkzeug/contrib/fixers.py.Copy
fixers.py
in the directory ofmoin_flup_wsgi.py
.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)
- Compile the 2 scripts with
py_compilefiles
:
py_compilefiles *.py
- 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', '')
License : CC-BY