I saw your post yesterday, just searching for an answer for exactly the same issue. Finally, today I reached the root of the problem.
I suppose you specify the chdir in your .ini config file as the directory where your project is located. I mean that if for example your project is 'myproject' and you have it in '/var/www/myproject' directory, you specify '/var/www' as the chdir.
So, the path for all internal resources is not well defined, and Python interpereter (may be you are using Django?) does not reach them. Ok, I will explain how a solution works in a Django project. For example, suppose that you have an app inside your project called 'app1'; in your views module you are calling for a forms defined in your forms module; you will be doing this like that:
from app1.forms import *
okay? Well, the thing is that the path is not well defined for uwsgi. You should now define this like that:
from myproject.app.forms import *
and you will see that everything is working now. No more 502 Bad Gateway errors will appear for you :)
Yes, I know that is not very elegant to add 'myproject.' to every internal resource calling. So, you can simply add this to your 'settings.py' file:
sys.path.append('/var/www/myproject/')
Substitute '/var/www/' for the path where your project is located on your machine. With this tiny solution, every started working for me :)
I hope my comment helps you.
Cheers,
Jose
Best Answer
Until a few minutes ago this was not possible. nginx would always buffer all uwsgi and scgi responses, and no configuration would change that.
I have submitted a patch for nginx (and it was accepted) and from the next version on there are two methods to disable buffering for uwsgi requests:
uwsgi_buffering off
in the nginx configX-Accel-Buffering
'no' header in the responseuwsgi never buffers the response, so no configuration is required on that end.