[BangPypers] Multiple Django app with nginx

Gora Mohanty gora at mimirtech.com
Thu May 19 14:20:17 EDT 2016


On 19 May 2016 at 09:01, Sathishkumar Duraisamy <bewithsathish at gmail.com> wrote:
[...]
>
>
> May be you are right. I am really sorry, with many django developers here
> in our local python list, I hoped to get solution.

I do think it is off-topic: It really has to do with understanding
how the proxy_pass directive in nginx works, and i is not just
about being off-topic. I still think that you would get better
answers on a nginx list. The fact that nginx is proxying to a
Django application is irrelevant here. Nevertheless, I am
bored at the moment :-)

[...]
> Below is my nginx configuration, with domain name changed to example.com.
> Here I two application one is Taiga which is basically django application
> and second one is green, which is again, home grown django application.This
> one is on second server( with different architecture with docker). I have
> checked with browser with address 10.135.48.188:8000 and is working good.

Your description points to a different issue: The problem is not
that there are multiple upstream servers (those seem to be
configured correctly, and should be working fine), but that you
are seeing what you feel to be an unexpected redirection.

> I could see the home page of green project:
>
> https://example.com/green/
>
> When I try to login with links in the home page of green, it is pointing to
> https://example.com/login instead of https://example.com/green/login. May
> be it is correct from nginx reverse proxy.
[...]

I think that this the crux of the confusion: While I cannot
test this now, the above redirection should be as expected
from your configuration. Viz., with the configuration:

location /green/ {
    proxy_pass      http://green_servers;
}

https://example.com/green/login should indeed redirect
to https://example.com/login

Maybe these links will help (I am unable to do more
without a test setup):
* nginx core documentation: Please read carefully the
  distinction between specifications with, and without
  a URI. Your /api and /green locations are different
  in this respect.
* Multiple examples of such configurations:
   http://www.liaohuqiu.net/posts/nginx-proxy-pass/

A final thing to watch out for is trailing-slashes in the
proxy-pass directive: The nginx behaviour here can
be quite confusing.

Regards,
Gora


More information about the BangPypers mailing list