[BangPypers] Multiple Django app with nginx

Gora Mohanty gora at mimirtech.com
Wed May 18 16:01:21 EDT 2016


On 19 May 2016 at 00:41, Sathishkumar Duraisamy <bewithsathish at gmail.com> wrote:
> Hi All,
>
> In Apache with help of modwsgi module we can mount may application like
>
>  WSGIScriptAlias /app1 /usr/local/www/wsgi-scripts/myapp1.wsgi
>  WSGIScriptAlias /app2 /usr/local/www/wsgi-scripts/myapp2.wsgi
>
> What is the similar approch for NGINX  web server? Any idea?

First of all, this is really off-topic here, and you are probably
better off asking
on a nginx list. Having said that, we regularly use nginx with
gunicorn, and what
you need to do is
* Set up an upstream server that defines the TCP/Unix domain socket that
  gunicorn is listening on. Something like:
   upstream app_server {
        server 127.0.0.1:80 fail_timeout=0;
    }
* Then, proxy to the app_server, e.g.,
       location @proxy_to_app {
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $http_host;
            proxy_set_header  X-Forwarded-Protocol https;
            proxy_redirect off;
            proxy_buffering off;
            proxy_pass   http://app_server;
        }

There are many detailed write-ups available by searching Google: See, e.g.,
http://michal.karzynski.pl/blog/2013/06/09/django-nginx-gunicorn-virtualenv-supervisor/

> I have been trying with reverse proxy along with gunicorn, but not able to
> achieve.
>
> I am trying to get mount as follows:
>
> http://exmaple.com/app1 --> 127.0.0.1:8000/
> http://exmaple.com/app1/home/ --> 127.0.0.1:8000/home/
[...]

Please show actual nginx configuration on the nginx mailing list rather than
pseudo-examples like this. Nobody can tell what you are actually trying.

Regards,
Gora


More information about the BangPypers mailing list