Note that there are some explanatory texts on larger screens.

plurals
  1. POServing a second application from a sub-path of another
    text
    copied!<p>I am trying to serve two django projects from the same server using WSGI, but require that one run from example.com/ (let's call that app1) and the other from example.com/foo/ (app2). I tried setting this up with separate daemon processes as described in Graham's comment <a href="http://mediacore.com/blog/hosting-multiple-wsgi-applications-with-apache" rel="nofollow">here</a>, but that appears not to work when one of the paths is a subdirectory of the other. All requests for example.com/foo/... are still being handled by the app1.</p> <p>Is there any way I can achieve what I'm looking for without needing to combine the two projects into one (which would be a difficult task)?</p> <p>This is what I currently have in my site configuration:</p> <pre><code>WSGIDaemonProcess app1 \ python-path=&lt;path for app1's virtualenv&gt; WSGIDaemonProcess app2 \ python-path=&lt;path for app2's virtualenv&gt; WSGIScriptAlias / &lt;path to app1's wsgi.py&gt; WSGIScriptAlias /foo/ &lt;path to app2's wsgi.py&gt; &lt;Location /&gt; WSGIProcessGroup app1 &lt;/Location&gt; &lt;Location /foo/&gt; WSGIProcessGroup app2 &lt;/Location&gt; </code></pre> <p>Update:</p> <p>I've tried using LocationMatch instead of Location to try to have every request to a path that doesn't start with /foo delegated to app1 and those that do to app2, but that doesn't work either for some reason. Now, requests to /foo/... result in a 500 error with this line in the error log:</p> <pre><code>mod_wsgi (pid=12032): Exception occurred processing WSGI script '&lt;app1's wsgi.py&gt;'. </code></pre> <p>Any ideas?</p> <p>The bottom of the above has been changed to</p> <pre><code>&lt;LocationMatch "^/(?!foo.*)"&gt; WSGIProcessGroup app1 &lt;/LocationMatch&gt; &lt;LocationMatch "^/foo.*"&gt; WSGIProcessGroup app2 &lt;/LocationMatch&gt; </code></pre> <p>Update 2:</p> <p>After looking at the error log further, it looks like the requests to /foo/... are being handled by app1's wsgi.py file, but using the python path for app2, meaning that the correct WSGIProcessGroup directive is being applied. Therefore, the problem appears to be a ScriptAlias collision. Is it possible to have this alias be a regex as well to make sure /foo... is not matched to /?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload