On 06/11/2014, at 3:41 PM, robert brook <[email protected]> wrote:
> > The Lan team has been struggling to install mod_wsgi through the traditional > approach without much luck in getting Apache to fire off django, so I was > looking for an alternative. And you aren't interested in trying to resolve what ever problem they had? Having it integrated into the front end Apache is still going to be the preferred solution. If you were wanting to use Python 3.3, I wouldn't be surprised if the issue was that they were trying to use a packaged version of mod_wsgi which was compiled against a different Python version. You can't force mod_wsgi compiled against one version to use a different Python version. > The mod-express was very simple to install and configure and got it to work > easily as a stand alone. I was trying to provide the Lan team with a > solution to a problem that they have not been able to resolve. If the > express implementation does not provide 2 tiers and good performance minimum > requirements, then it will not meet our requirements. > > The link below implies that express can be configured through a traditional > apache 2 tier server approach. > http://stackoverflow.com/questions/26766141/hosting-multiple-django-sites-with-mod-wsgi-express-apache > > Is that correct, can a 2 tier apache be configured to utilize the mod_wsgi > express command? It is certainly possible to use mod_wsgi express behind a front end proxy and using it behind an nginx front end is even recommended as nginx will isolate the Apache/mod_wsgi instances from slow HTTP clients. Although you can use Apache as a front end proxy, you don't get as many benefits as would using nginx as the front end because of the differences in how they work. That said, presuming you only have one Django instance you want to run in this way with it taking the whole site name, the front end Apache would be set up with something like: ProxyPass / http://localhost:8000 ProxyPassReverse / http://localhost:8000 The mod_proxy_http module when using ProxyPassReverse will automatically set headers on the proxied request for: X-Forwarded-For X-Forwarded-Host X-Forwarded-Server I am not entirely sure if Django honours these by default or not. I thought recognition of them had been taken out, but it is still talked about in: https://docs.djangoproject.com/en/dev/ref/request-response/#django.http.HttpRequest.get_host If the front end is going to terminate HTTPS connections, you probably also want to set the directive, in the Apache front end: RequestHeader set X-Forwarded-Proto "https" This would be in the SSL VirtualHost. Then in the Django settings ensure you are setting SECURE_PROXY_SSL_HEADER appropriately. Anyway just highlighting you may have to set a few things up simply due to the use of a proxy if you need to know the details of the original client. As to mod_wsgi-express, now run it on port 8000. A few variations to now consider. If you don't want the site mounted at the root but at a sub URL. Thus: ProxyPass /suburl http://localhost:8000/suburl ProxyPassReverse /suburl http://localhost:8000/suburl Then you need to supply the --mount-point option to mod_wsgi express so that it uses a matching mount point to the front end. Thus: --mount-point /suburl If you don't, when absolute URLs are created as necessary by the Django site they will not match what the front end is accepting. If you need to run two Django sites, it is better and easier to run two instances of mod_wsgi-express on different ports and set up multiple proxy directives for that in the Apache front end. You do not want to go try modifying the generated configuration of mod_wsgi-express to try and run two Django instances that way as it defeats the purpose of what mod_wsgi-express is aimed at. So yes you can certainly use it in a so called 2 tier arrangement. Beyond those quick tips you would need to be more specific about what you need to know if you are unsure of what to do. Graham > On Wednesday, November 5, 2014 10:39:45 PM UTC-5, Graham Dumpleton wrote: > > On 06/11/2014, at 2:28 PM, robert brook <[email protected]> wrote: > >> I have downloaded and successfully run mod_wsgi as a python plugin from the >> following site >> https://github.com/GrahamDumpleton/mod_wsgi >> >> I have run the test scripts successfullly for django from one server in >> which apache and django are on the same server >> mod_wsgi-express start-server >>this works as expected >> mod_wsgi-express start-server wsgi.py >> this works as expected >> (I had to move the wsgi.py file up one directory level to have the web site >> render correctly. > If wish to use mod_wsgi-express, for a Django site, you are better off > integrating mod_wsgi as an installed application with Django. See section > 'Using mod_wsgi express with Django' of: > > https://pypi.python.org/pypi/mod_wsgi > > By doing that, the runmodwsgi management command will then make sure that > Python module search paths, access to static files etc is correct. > > Have you read the documentation on the PyPi page and tried that method? > > What version of Django are you using? > > How much have you changed around things from the standard Django layout? > >> How do I install and configure this to work on a 2 tier apache / django >> application. >> When I perform the setup.py install, does the apache installation get >> touched by the installation? >> And can this be used for Production assuming that I can configure a 2 tier >> installation? > I am not too clear on what you are trying to achieve. > > Are you talking about using mod_wsgi-express behind another front end Apache > instance where the first Apache is merely proxying to the second Apache > instance started up by mod_wsgi-express? > > Generally if you have a working Apache instance already on the system > fulfilling other purposes, you would use mod_wsgi installed direct in to it. > For that you would not use mod_wsgi-express but the more traditional way of > building and installing mod_wsgi. You would then follow setup instructions as > given in the Django documentation for mod_wsgi: > > https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/modwsgi/ > > Can you perhaps clarify what you are trying to do and whether you have an > existing Apache installation you need to use. > > Graham > > -- > You received this message because you are subscribed to the Google Groups > "modwsgi" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/modwsgi. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "modwsgi" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/modwsgi. For more options, visit https://groups.google.com/d/optout.
