[Moin-user] Configuring URL prefix for Moin served via Nginx + Gunicorn

Darren Spruell phatbuckett at gmail.com
Tue May 27 03:27:29 EDT 2014


Greetings,

MoinMoin 1.9.7
Gunicorn 18.0
Nginx 1.4.1

I have a single wiki instance that works correctly when served from
the root of my site (/). I want to migrate it on the site now to be
served from /wiki/home/ (e.g.
http://www.example.org/wiki/home/HelpContents). When I configure this
on Nginx and then set 'url_prefix_static' in the MoinMoin config, wiki
pages are not served correctly. i.e. attempting to access
http://www.example.org/wiki/home/ attempts to load a page named
'wiki/home' and MoinMoin returns 404 with "This page does not exist
yet. You can create a new empty page, or use one of the page
templates."

I cannot find a config option to instruct MoinMoin that it is being
served from a subdirectory of the site and to therefore operate under
a URL prefix. I understand that 'url_prefix_static' is only for static
media. I notice that
http://moinmo.in/HelpOnConfiguration#Configuration_of_multiple_wikis
documents a config option 'url_prefix' however various references make
it look as if that setting is no longer used/suggested.

Gunicorn is a WSGI server but as opposed to uwsgi it uses standard
HTTP as a service protocol; I think this prevents one from passing
environment settings (such as SCRIPT_NAME) as one would for e.g. FCGI
or UWSGI, etc. However I notice that placing the following in my
moin.wsgi seems to fix he path finding:

os.environ['SCRIPT_NAME'] = '/wiki/home'

To me, this seems like more of a hack than a solution.

Current config details:

# Nginx config section
location /wiki/home {
    try_files           $uri @wiki_home_rewrite;
}
location @wiki_home_rewrite {
    proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header    Host $http_host;
    proxy_redirect      off;
    proxy_pass          http://127.0.0.1:8001;
}

# wikiconfig.py
class Config(multiconfig.DefaultConfig):
    ...
    url_prefix_static = '/wiki/home' + url_prefix_static
    ...

Is there a way to configure MoinMoin to understand that it is being
served from a URL with a prefix path and operate as desired without
modifying the environment in the WSGI driver script?

-- 
Darren Spruell
phatbuckett at gmail.com




More information about the Moin-user mailing list