sockets - wsgi nginx error: permission denied while connecting to upstream -
there seem many questions on stackoverflow unfortunately nothing has worked me.
i'm getting 502 bad gateway on nginx, , following on logs: connect() ...myproject.sock failed (13: permission denied) while connecting upstream
i'm running wsgi
, nginx
on ubuntu
, , i've been following this guide digital ocean. apparently configured wsgi
correctly since uwsgi -s myproject.sock --http 0.0.0.0:8000 --module app --callable app
worked, keep getting nginx
permission denied error , have no idea why:
after coming across this question , this other one, changed .ini
file , added chown-socket
, chmod-socket
, uid
, gid
parameters (also tried setting first two, either or, , couple of different permission settings --and permissive didn't work).
this 1 seemed promising, don't believe selinux
installed on ubuntu (running sudo apt-get remove selinux
gives "package 'selinux' not installed, not removed" , find / -name "selinux"
doesn't show anything). in case, though, tried this post recommended well. uninstalling apparmor
(sudo apt-get install apparmor
) didn't work either.
every time make change, run sudo service nginx restart
, see 502 gateway error (and permission denied error when read logs).
this is nginx
configuration file:
server { listen 80; server_name 104.131.110.156; location / { include uwsgi_params; uwsgi_pass unix:/home/user/myproject/web_server/myproject.sock; } }
.conf
file:
description "uwsgi server instance configured serve myproject" start on runlevel [2345] stop on runlevel [!2345] setuid user setgid www-data env path=/root/.virtualenvs/my-env/bin chdir /home/user/myproject/web_server exec uwsgi --ini /home/user/myproject/web_server/myproject.ini
.ini
file:
[uwsgi] module = wsgi master = true processes = 5 socket = /home/user/myproject/web_server/myproject.sock chown-socket=www-data:www-data chmod-socket = 664 uid = www-data gid = www-data vacuum = true die-on-term = true
(if helps, these specs of digital ocean machine: linux 3.13.0-43-generic #72-ubuntu smp mon dec 8 19:35:06 utc 2014 x86_64 x86_64 x86_64 gnu/linux
)
please let me know if there's can do, , thank much.
i followed tutorial , ran same issue. after quite bit of trial , error, following steps allowed me run uwsgi , nginx successfully:
my nginx.config
file:
server { listen 80; server_name localhost; location / { try_files @yourapplication; } location @yourapplication; { include uwsgi_params; uwsgi_pass unix:/path_to_project/project.sock; } }
my .ini
file wasn't working well, decided take advantage of uwsgi's extensive arguments available. here's used:
uwsgi -s /path_to_project/project.sock -w wsgi:app -h /path_to_project/venv --http-processes=4 --chmod-socket=666 --master &
where:
-s /path_to_project/project.sock
= location of .sock
file
-w wsgi:app
= location of wsgi.py
file , app
being name of flask object
-h /path_to_project/venv
= location of virtual environment
--http-processes=4
= number of http processes uwsgi create
--chmod-socket=666
= permissions set on socket
--master
= allow uwsgi run master process manager
&
= run uwsgi in background
hope helps!
Comments
Post a Comment