title: ProxyPass and ProxyPassReverse for Django app
body: <p>I have a follow up question from my original <a href="https://stackoverflow.com/questions/12320803/serving-django-apps-using-mod-wsgi-from-a-site-that-does-not-run-django-from">Django serving question</a> which was how to develop Django apps and serve them from the same server as my main PHP-based site (all part of a larger migration of my website from a static and PHP driven one to a series of Django apps).</p>
  
  <p>I couldn't quite use the name server solution I was provided with, and instead just deployed my Django applications on a different port (8000) using mod_wsgi. Now, however, I need to actually integrate the Django application into the main site. In my Apache 2.0 configuration file (for say <a href="http://www.example.com" rel="nofollow noreferrer">http://www.example.com</a>) I added the following ProxyPass commands (after my mod_wsgi initialization):</p>
  
  <pre><code>ProxyPass        /app/newsletter     http://www.example.com:8000/app/newsletter
  ProxyPassReverse /app/newsletter     http://www.example.com:8000/app/newsletter
  </code></pre>
  
  <p>Here I expect that any request to:</p>
  
  <pre><code>http://www.example.com/app/newsletter
  </code></pre>
  
  <p>will get successfully proxied to:</p>
  
  <pre><code>http://www.example.com:8000/app/newsletter
  </code></pre>
  
  <p>and all will be right with the world.</p>
  
  <p>However, this is not the case. Apache hangs for 5 or so minutes (the time taken to craft this question) then spits out a <strong>502 Proxy Error</strong>:</p>
  
  <pre><code>Proxy Error
  
  The proxy server received an invalid response from an upstream server.
  The proxy server could not handle the request GET /app/newsletter/.
  
  Reason: Error reading from remote server
  </code></pre>
  
  <p>Watching my Apache 2.0 error log after this response I see continuous errors like the following:</p>
  
  <pre><code>[Thu Sep 27 15:25:49 2012] [error] Exception KeyError: KeyError(****,) in &lt;module 'threading' from '/usr/lib64/python2.6/threading.pyc'&gt; ignored
  </code></pre>
  
  <p>So something seems to be remiss in either how mod_proxy plays with Django and/or Python. I have other Java related processes that I use ProxyPass and ProxyPassReverse on and they work fine. Also, when I don't try to apply the ProxyPass the Django apps all work well (ie. when I address them on port 8000 directly).</p>
  
  <p>Any ideas? I don't feel like what I am doing is particularly complex.</p>
  
  <p>Thanks in advance.</p>