We have an application written in django. We are trying a deployment scenario which will have one docker running apache, the second docker running django and the third docker running the DB server. In most of the documentation it is mentioned that apache and django will sit on the same machine (django in virtualenv to be precise), is there any way we can ask apache to talk to mod_wsgi sitting on a remote machine which has the django application?
mod_wsgi would be the wrong technology if you want to do this. It runs as part of Apache itself, so there literally is nothing to run in the Django container.
A better way would be to use gunicorn to run Django in one container, and have the other running the webserver as a proxy - you could use Apache for this, although it's more common to use nginx.
Related
I know it might be a bad design but since we are developing the django website on our laptops which runs Win7, I thought it would be better to run django on a Windows platform only in production.
(Laptop is not powerful enough to run a Unix VM inside and our Unix team doesn't provide any Unix server with UI access (Only Putty) so using an IDE is impossible on Unix.)
I have deployed django with gunicorn and nginx on a Linux server very easily, but this time I have to deploy django on a Windows server with Apache on another Unix server (I know it sucks).
Our middleware team is asking(forcing) to run django components on a separate server so that they can manage their Apache (on Unix) instance comfortably. As far as I understand, Apache and django should reside on the same server for mod_wsgi to work.
Is this possible to keep Apache on a Unix machine and make a django website run from a Windows machine?
If not, what are the best possible solutions in my case? (Switch django on Unix? Use waitress on Django windows? Do not separate Apache and Django? etc.)
Regards,
Aditya
Try deploying on IIS instead, as it is the native Web Server on Windows Servers.
Checkout the django-windowsauth package, you can use it to deploy your project to IIS using few simple commands. https://github.com/danyi1212/django-windowsauth.
The best thing in my modest point of view is to create a unix docker image of your project
I have an Linux instance running on Google Compute Engine. I installed pip and django on it and cloned a Django project that I worked on locally. Like I would on localhost I ran my app like so: python3 manage.py runserver 0.0.0.0:8080, and my server was up and running with no problems. I read online on how WSGI servers are required for python apps to run well on servers however I don't see why I would need something like gunicorn to run my app
Here's what the documentation for runserver says:
DO NOT USE THIS SERVER IN A PRODUCTION SETTING. It has not gone through security audits or performance tests. (And that’s how it’s gonna stay. We’re in the business of making Web frameworks, not Web servers, so improving this server to be able to handle a production environment is outside the scope of Django.)
Django's runserver is itself a WSGI server, but it's aimed at being easy for developers to use.
Production WSGI servers like uWSGI and Gunicorn have performance and production environments in mind. They handle concurrency better, they are faster, and are built to withstand malicious users, not just developers.
When I deploy openerp/odoo using mod_wsgi, I found my schedulers stop working, can any one help how can I get my cron/schedulers working. If I deploy it using mod_proxy it will solve the issue but I want to deploy using mod_wsgi.
The schedulers don't work when running through wsgi because your Odoo instances are just workers. AFAIK you just run a standalone instance on a 127.0.0.1 port and it runs your scheduled tasks.
I have a locally developed Pylons application. I also have hosting provider with SSH access, python 2.6 and have set a virtual environment on the server. After that using easy_install I have installed Pylons and achieved to execute it on port XXXX. The problem is that the firewall of the server is blocking any port other from 80 (the port of the Apache http). Can I redirect Apache to forward to my Pylons server?
If you are in jail or virtual container where running your isolate instance of apache, just kill it.
You can see process list by execute 'top' utility.
You need to configure a virtualhost in apache so that it uses wsgi.
There's a plenty of topics in stackoverflow about this, such as
Trying to get Pyramid running under Apache + mod_wsgi but it's failing
(you can follow the link in the first sentence).
If you cannot use mod_wsgi, that you can try with mod_rewrite or mod_proxy, which have worse performance. If you cannot change the apache configuration, ask you provider, or start thinking about changing provider.
I am looking to run standalone python scripts through fcgi for use with nginx, but I have no idea where to start with spawning the processes. Currently, I have PHP successfully with nginx+fcgi, but I'm unsure if/how I can do the same with python. Any suggestions on where to start?
See the python docs section on FCGI. Basically, with Python, you use the WSGI interface on top of an fcgi server which talks to the web server (the fcgi client).
See Python + FastCGI for a couple of Python fcgi servers.
Edit:
This nginx wiki page explains exactly how to set up Python with nginx using fcgi.
This wiki page describes the uWSGI module for nginx, which is the natural way to use Python with a web server, if you don't really need to use fcgi. This blog entry also looks like good info on uWSGI.
In production, Apache + mod_wsgi or Nginx + mod_wsgi? has some useful info for nginx mod_wsgi as well.