Nginx timeouts when uWSGI takes long to process request

前端 未结 4 1313
暗喜
暗喜 2021-01-31 15:05

I have Nginx + uWSGI for Python Django app.

I have the following in my nginx.conf:

location / {
    include uwsgi_params;
    uwsgi_pass            


        
4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-31 15:49

    In addition to the "uwsgi_read_timeout" answer, you should also check that ownership is correct for your nginx uwsgi cache directory. Ownership must be set to the same user as the running nginx process... In my case I had to do this

    grep '^user' /etc/nginx/nginx.conf
    ls -lah /var/cache/nginx/uwsgi_temp
    for f in $( find /var/cache/nginx/uwsgi_temp ); do ls -lah $f; done
    

    Are these files owned by the same user? If not, you could shut down nginx and remove all the cache files, make sure that the proper owner is on /var/cache/nginx/uwsgi_temp and restart. Maybe you could also just do a recursive chown, I didn't test this approach.

    # store the user
    THEUSER=$(grep '^user' /etc/nginx/nginx.conf | sed 's/.* //; s/;.*//' )
    

    Remove cache and restart approach

    /etc/init.d/nginx stop
    rm -rf /var/cache/nginx/uwsgi_temp/* 
    chown $THEUSER:$THEUSER /var/cache/nginx/uwsgi_temp
    /etc/init.d/nginx start
    

    Recursive chown approach

    chown -R $THEUSER:$THEGROUP /var/cache/nginx/uwsgi_temp/
    # not sure if you have to restart nginx here... 
    

提交回复
热议问题