On Tue, May 27, 2014 at 11:17 AM, Paul Boddie <p...@boddie.org.uk> wrote: > On Tuesday 27. May 2014 09.27.29 Darren Spruell wrote: >> 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." > > So you first need to make sure that Moin is served for that resource and not > the root resource, and you then need to let Moin know that it is rooted at > this new resource itself.
Sounds so simple! :) >> 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. > > Yes, there's a mention of it in wikiconfig.py files that I've seen, but it > appears to be obsolete. As it turns out, my attempting to find an option like this (configure the wiki software to know what path it is served from) is a habit formed from using various other software including at least one wiki engine which uses a setting like this: $wgScriptPath = "/wiki/work"; I guess what I missed is that it's not necessarily MoinMoin that needs to be told this, but the WSGI server hosting MoinMoin? >> 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' > > Well, this should be presented to Moin by the Web server: that's what it is > for! However, in moin.wsgi, you might be able to set the fix_script_name > setting instead. Was curious about this, did not see this setting in the installed moin.wsgi but did find it in the FCGI driver script. >> 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? > > If you can get away with fix_script_name, then yes. Otherwise, perhaps not. > Again, without things like SCRIPT_NAME, scripts know nothing about their > environment or the way they are deployed. And I guess this was the key. Stumbled into this FAQ entry: http://gunicorn-docs.readthedocs.org/en/latest/faq.html#how-do-i-set-script-name The resulting configuration in Nginx's configuration that works for me: 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_set_header SCRIPT_NAME /wiki/home; proxy_redirect off; proxy_pass http://127.0.0.1:8001; } Having SCRIPT_NAME sent literally as a request header is ...interesting, but seems to be what Gunicorn is expecting (if not set as an env var). Will add a blurb at http://moinmo.in/HowTo - anything else of note about this? -- Darren Spruell phatbuck...@gmail.com ------------------------------------------------------------------------------ Time is money. Stop wasting it! Get your web API in 5 minutes. www.restlet.com/download http://p.sf.net/sfu/restlet _______________________________________________ Moin-user mailing list Moin-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/moin-user