[Fixed]-Nginx reverse proxy for nginx+gunicorn+django server

1👍

It seems that your django app does not have a router for /django_app path. You will have to either do a rewrite from /django_app in the reverse_proxy to / on the “django_server.com” server or configure a route in your app.

try adding the location below to your django_server.com server:

... 

location ~ ^/django_app(.*)$ {
  try_files $uri $1 /$1;
}

location / {
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_set_header X-Forwarded-Proto $scheme;

  proxy_set_header Host $http_host;
  proxy_redirect off;

  proxy_pass http://gunicorn_socket/;
}

Leave a comment