Nginx – uwsgi dying when nginx runs under different user

djangonginxuwsgi

I'm using Django with nginx/uWSGI. I have to serve files off a mount that a particular service account, mybic, has read access to, so I've had to change the nginx user from:

user nginx;

to

user mybic dbhi_bic;

This has caused my Django web app to hang and die.

Here are the errors:

Fri Mar 24 15:37:36 2017 - SIGPIPE: writing to a closed pipe/socket/fd (probably the client disconnected) on request /foo/bar/ (ip 123.45.67.890) !!!
Fri Mar 24 15:37:36 2017 - uwsgi_response_write_body_do(): Broken pipe [core/writer.c line 331] during GET /foo/bar/ (123.45.67.890)
IOError: write error

I assume this is some kind of permissions error but I'm not sure which directories and files user nginx normally writes to that I need to worry about.

Best Answer

OK this is caused by the initial creation of /var/lib/nginx as a 700 permissions directory. It must be chown'ed manually for nginx to work properly as a new user.

chown -R mybic:dbhi_bic /var/lib/nginx/