-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I have been trying to get nginx to talk to uwsgi to no avail. uwsgi
works by itself as I can host it on port 80 on my local machine with no
problems. I have tried configuring nginx with the following variations:
option 1
location / {
include uwsgi_params;
uwsgi_pass unix:/tmp/uwsgi.sock;
}
option 2
location / {
include uwsgi_params;
uwsgi_pass unix:///tmp/uwsgi.sock;
}
option 3
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:3000;
}
These are the corresponding errors I get:
option 1
option 2
2014/10/08 14:24:39 [crit] 15736#0: *8 connect() to
unix:///tmp/uwsgi.sock failed (2: No such file or directory) while
connecting to upstream, client: 127.0.0.1, server: localhost, request:
“GET / HTTP/1.1”, upstream: “uwsgi://unix:///tmp/uwsgi.sock:”, host:
“127.0.0.1”
option 3
Steven Williams
My PGP Key:
http://pgp.mit.edu/pks/lookup?op=get&search=0xCACA6C74669A54FA
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
iQIcBAEBAgAGBQJUNoNoAAoJEMrKbHRmmlT6pWkP/i5w/RJdEKOS9C22W6WxIbmr
MjrTH4L0FwrCizZnI+dV+2XnYSEkky4GzefaoffpoWsr/sfA7UwMYfjSiYrWcxxE
3U4mbyJVpxiJmafVswoifKJspHTGtsFDwigm0/k04TTml8exPK9sjLUFF4I/um7H
CzEOvHahC1GIaeEWl+38GZAmSnBNo99TGSpQKzWaZ9zw5hed+ySkVj/nMIijNp0Y
euLOKuH93JzSgRAY54fxVd8J+mLRh+HX/NUfAkEoDtJ2Bq6ltcgTmy4Q5HHTwrxP
8ekQk1Pmea7SMFiAU/zkD4WVTp3tyXX5F31DtTXXzGKVTt0VJZBbmXK1AwIO8H9h
RyVyg10T5+4PCPWSpn7SLtAgdDupb7YXTXP4Owov7P47bawy6+z+9LaE5/IWc8V7
DY477LLmnbYK0M8voJcgcIVLWsS65yTr8l7S6tXBI8ONRmiPvr33MInGy14JefCv
fXCkeCOYCwa6dVGLFHMHpDLcSWzxPPCSMjHyTOu2KpTpjwJO7qGpoZVXlrKt+Qkq
JeFCAhbSAsPI1v8dcf5JzXXz1bjnOKhSVWQFgYg+MTqNoWq3oG1JLhuO19VR4Wb/
Kol91PhT6FkQITMWeBNftMqzatuk1sD5vXxl8kgycJTFCbtys64DKGgBmpkyfa56
2z62sKR23yH7VJuu4knb
=9laf
-----END PGP SIGNATURE-----
Option #2 should work, here’s what I have for my uwsgi site. Double
check
your permissions on the directory the uwsgi.sock lives in.
My nginx conf:
location / {
uwsgi_pass unix:///var/www/my_app/my_virtualenv/run/uwsgi.sock;
include uwsgi_params;
}
Directory permissions:
$ ls -la /var/www/my_app/my_virtualenv/run/
total 12
drwxr-xr-x 2 www-data www-data 4096 Sep 29 13:03 .
drwxr-xr-x 7 www-data www-data 4096 Jul 22 23:05 …
srwxr-xr-x 1 www-data www-data 0 Sep 29 13:03 uwsgi.sock
My vassal contains:
[uwsgi]
socket = /var/www/my_app/my_virtualenv/run/uwsgi.sock
uid = www-data
gid = www-data
On Thu, Oct 9, 2014 at 5:45 AM, Steven Williams <
Shouldn’t matter that you don’t have a www-data user, that just happens
to
be the one I am using. I am running uwsgi in emperor mode so my worker
processes have that uid
$ ps aux | grep uwsgi
root 798 0.0 0.0 31748 2296 ? Ss Sep29 0:24
/var/www/my_app/my_virtualenv/bin/uwsgi --emperor
/var/www/my_app/my_virtualenv/vassals
www-data 805 0.0 0.4 110688 16944 ? S Sep29 0:35
/var/www/my_app/my_virtualenv/bin/uwsgi --ini www.myapp.com.ini
www-data 898 1.2 5.5 413076 213776 ? S Sep29 189:06
/var/www/my_app/my_virtualenv/bin/uwsgi --ini www.myapp.com.ini
I also don’t think it matters that you don’t have a vassal setup,
probably
doesn’t make a big difference just for testing stuff out.
Perhaps you need to try messing with the chmod-socket
http://stackoverflow.com/questions/22071681/permission-denied-nginx-and-uwsgi-socket
parameter? I’m not sure.
I don’t know of a good guide to follow, I had to piece mine together
from a
bunch of different guides of varying quality until I got it working.
Greg
On Thu, Oct 9, 2014 at 1:52 PM, Steven Williams <
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 10/09/2014 12:49 PM, Greg Barker wrote:
Option #2 should work, here’s what I have for my uwsgi site.
Double check your permissions on the directory the uwsgi.sock lives
in.
My nginx conf: location / { uwsgi_pass
unix:///var/www/my_app/my_virtualenv/run/uwsgi.sock; include
uwsgi_params; }
Changed my configuration to use the unix:/// notation. Still no change
as I am getting a 50x type error.
Directory permissions: $ ls -la /var/www/my_app/my_virtualenv/run/
total 12 drwxr-xr-x 2 www-data www-data 4096 Sep 29 13:03 .
drwxr-xr-x 7 www-data www-data 4096 Jul 22 23:05 … srwxr-xr-x 1
www-data www-data 0 Sep 29 13:03 uwsgi.sock
The permission bits match (755), but they are root. On my system
(Fedora 20 on my laptop; CentOS 7 on my VPS) I do not have a www-data
user or group.
My vassal contains: [uwsgi] socket =
/var/www/my_app/my_virtualenv/run/uwsgi.sock uid = www-data gid =
www-data
I don’t have a vassal setup, but that doesn’t make a huge difference
for just testing does it?
Is there a good, current thorough guide that I can follow?
Steven Williams
My PGP Key:
http://pgp.mit.edu/pks/lookup?op=get&search=0xCACA6C74669A54FA
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
iQIcBAEBAgAGBQJUNvWVAAoJEMrKbHRmmlT6rgkP/3oFcVvKss3Aaf9Vv9BkOxmL
U3t6TZ72MNpWZhDHz85iOSKrElr7ehiXwIpgEC+Id+2+cJzHPIoBsakw94vcqUeK
pVhI8yJ7rqLVryXLYo5rFnXyQl4AvOP6HlRUPPbtGuF81BaAGYi5kuUQdddLzK7T
558wycBN7ZhO5+/UTKqHEohlp+cc9StTkxzy5tcI5/2mJjYkxcusPua1dTW3hJjg
rypT7S0QBA9pwahdVHdSofySnwNG53fvE4gmwlkDpxJzS04gNw4LHsKeP4v9dU3X
5Qiibmtfd2GKw8C4JpPfJXsqObJHyc6sIRP2bHZ102QekwidgeXE7LpZTn9jHl4b
PYN22at8PPBNSWmPnxiEMIvPvAWDeoS1390ADUGFQ4nDK9iM/DTWaQ1u+T59XooB
oXYuzCSqgKmDN5aRYfLQRpEXORb/ur6LCQfCLlthuSZJnPt1jeUtz9zJghos88i2
vXyJo2DKswYEV9gwoeeStntZ/NfKib990lUS5R47e5yE9y2JXk1jPi8VeZ2omWVl
SMKNQF/6w30625OQEXLxylG8Yjxzkox/Cz33+ywL179UZghmNY5X4vHrH22DpjVA
FIFjDlkC5KfuhMf7jvFhummL9u9DVFaWXZTpDTvb/POrFdJJH2p1eDcNgzfV0mqK
i30xy/3rHRgGZpT/1sWL
=afHF
-----END PGP SIGNATURE-----
uwsgi_params; }
The permission bits match (755), but they are root. On my system
Is there a good, current thorough guide that I can follow?
This covers basically any aspect of a production ready-deployments:
http://uwsgi-docs.readthedocs.org/en/latest/WSGIquickstart.html
as you can see it uses tcp sockets when describing nginx integration.
This
avoid you to start messing with permissions (btw, the process connecting
to the unix socket, nginx in your case, must have write permission on
the
socket).
Read and follow the whole quickstart from start to end, as it
progressively introduces concepts
–
Roberto De Ioris
http://unbit.it
On Thursday 09 October 2014 10:49:38 Greg Barker wrote:
Option #2 should work, here’s what I have for my uwsgi site. Double check
your permissions on the directory the uwsgi.sock lives in.
My nginx conf:
location / {
uwsgi_pass unix:///var/www/my_app/my_virtualenv/run/uwsgi.sock;
include uwsgi_params;
}
[…]
Actually, these two extra slashes are surplus.
Look at the docs: http://nginx.org/r/uwsgi_pass
wbr, Valentin V. Bartenev
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 10/10/2014 12:13 AM, Roberto De Ioris wrote:
Read and follow the whole quickstart from start to end, as it
progressively introduces concepts
That did the trick. Apparently SELinux was interfering with Nginx
connecting by the port number. I adjusted the policy and everything is
working fine now. Thank you for telling me to read the guide from
start to finish.
For posterity’s sake all nginx needed was:
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:3031;
}
$ uwsgi --socket 127.0.0.1:3031 --wsgi-file run.py
In order to get that working under Fedora and CentOS you have to
adjust the running SELinux policy which you can do with the following:
$ sudo cat /var/log/audit/audit.log | grep nginx | grep denied |
audit2allow -M mynginx
$ sudo semodule -i mynginx.pp
Thanks guys.
Steven Williams
My PGP Key:
http://pgp.mit.edu/pks/lookup?op=get&search=0xCACA6C74669A54FA
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
iQIcBAEBAgAGBQJUOr+tAAoJEMrKbHRmmlT6mgwP/0hW3iZhGzFOlNp1XJp3ALs0
xVA3DISGzf8uigJXDnARNIcLRDzw16f8SeTpYYZs8YLZStvx0xaJYsdj9Us9rPLC
dymF1kO3CwKjsuAS4Os94ENCFqzob5cqNdN6sp0dV1U1MLX17R1mvLych5WCosJp
aFL6eMoP/CFI9cbfS1kbMLowVSOfjOmsq9R6ZVrvkEUM9hSH1gRmXbvJR6bMW7Sz
vEH0eCLmL8/Z40YcX9ChXMvpZd1NoOLfMMQo/yKCHtrQQ/OBiSTPKu76KgIxNaiJ
k5tDC6cAKw0xhvQ3XsT7skMiMRrUUozpnouhS7ochTXcQaXBKJ2uEA0qMgPhRgom
K+OwJxrAAB0KglyLKdjiaNysI06Oy+eMn+WBQDX5BOVg35RjcWc/v8gRbdCSrLLO
iTMma5uCReHLhfuPignMYOHQNWpwUwxygbHzSNGbs7rFDe8HQkC6UZA8r7Qzs7fD
as6xPAjs3oTuW2fJRzOolzVO0qKmo1D/XQIL3YiscTYnqyololHdCGUgkz+a5NYY
B9xgYgrI1NIYos2+L8mfvTeEj2xe2AMm1KU/3tepVoDc+2lle2dzl8utC2LJCKbU
0jaQhmjyzY4MKW11L6qHA17Do3GlKTp4mlQIl141pNSf1SY4ik3RyhKos6SnSWUN
3VXEKnnHUH4yS1hoiV4j
=TG21
-----END PGP SIGNATURE-----