unbit / uwsgi-docs

Official uWSGI docs, examples, tutorials, tips and tricks
MIT License
638 stars 346 forks source link

sock file fails to initialize 'permission denied'. #418

Open tunage opened 6 years ago

tunage commented 6 years ago

I am getting 'permission denied' when I try and connect to my url.

nginx version: nginx/1.10.3
Starting uWSGI 2.0.17.1 (64bit)

My config is new and vhost.

log error:

2018/09/22 10:38:28 [crit] 32207#32207: *1 connect() to unix:/run/uwsgi/fixdsite.sock failed (2: No such file or directory) while connecting to upstream, client: 73.135.97.117, server: fixdsite.com, request: "GET /fixdsite/ HTTP/1.1", upstream: "uwsgi://unix:/run/uwsgi/fixdsite.sock:", host: "fixdsite.com"

uwsgi-site.ini:

$ cat /etc/uwsgi/sites/fixdsite.ini
[uwsgi]
project = fixdsite
uid = serveruser
gid = www-data
base = /home/%(uid)

chdir = %(base)/%(project)
home = %(base)/Env/%(project)
module = %(project).wsgi:application

master = true
processes = 5

socket = /run/uwsgi/%(project).sock
chown-socket = %(uid):www-data
chmod-socket = 664
vacuum = true

catch-exceptions = true

passwd file:

# cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
systemd-timesync:x:100:102:systemd Time Synchronization,,,:/run/systemd:/bin/false
systemd-network:x:101:103:systemd Network Management,,,:/run/systemd/netif:/bin/false
systemd-resolve:x:102:104:systemd Resolver,,,:/run/systemd/resolve:/bin/false
systemd-bus-proxy:x:103:105:systemd Bus Proxy,,,:/run/systemd:/bin/false
syslog:x:104:108::/home/syslog:/bin/false
_apt:x:105:65534::/nonexistent:/bin/false
messagebus:x:106:110::/var/run/dbus:/bin/false
uuidd:x:107:111::/run/uuidd:/bin/false
lightdm:x:108:114:Light Display Manager:/var/lib/lightdm:/bin/false
ntp:x:109:116::/home/ntp:/bin/false
avahi-autoipd:x:110:119:Avahi autoip daemon,,,:/var/lib/avahi-autoipd:/bin/false
avahi:x:111:120:Avahi mDNS daemon,,,:/var/run/avahi-daemon:/bin/false
dnsmasq:x:112:65534:dnsmasq,,,:/var/lib/misc:/bin/false
colord:x:113:123:colord colour management daemon,,,:/var/lib/colord:/bin/false
geoclue:x:114:124::/var/lib/geoclue:/bin/false
serveruser:x:1000:1000:serveruser,,,:/home/serveruser:/bin/bash

directory permissions:

# ls -l /run/u*

drwxr-xr-x  2 serveruser www-data   40 Sep 22 01:18 uwsgi

My sites-available file:

server {
        listen 80;
        listen [::]:80;

        root /var/www/fixdsite.com/html;
        index index.html index.htm index.nginx-debian.html index.php;
        server_name fixdsite.com www.fixdsite.com;
        location = /favicon.ico { access_log off; log_not_found off; }
        location /static/ {
                root /home/fixdsite;
        }
        location / {
                include         uwsgi_params;
                uwsgi_pass      unix:/run/uwsgi/fixdsite.sock;
                try_files $uri $uri/ =404;
        }

How do I get nginx/uwsgi to open the .sock file? nginx fails with permission denied.

Note: I can start the server manually with

uwsgi -s /run/uwsgi/fixdsite.sock

as the proper user and then the sock appears. But nginx is supposed to be doing that via the uwsgi module and not me.

session:

*** Starting uWSGI 2.0.17.1 (64bit) on [Sat Sep 22 15:44:18 2018] ***
compiled with version: 5.4.0 20160609 on 21 September 2018 09:17:43
os: Linux-4.13.0-43-generic #48~16.04.1-Ubuntu SMP Thu May 17 12:56:46 UTC 2018
nodename: dell
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 4
current working directory: /var/www/fixdsite.com/html/fixdsite
detected binary path: /usr/local/bin/uwsgi
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 30468
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address /run/uwsgi/fixdsite.sock fd 3
Python version: 3.5.2 (default, Nov 23 2017, 16:37:01)  [GCC 5.4.0 20160609]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x139d270
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 72920 bytes (71 KB) for 1 cores
*** Operational MODE: single process ***
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 8484, cores: 1)
akx commented 6 years ago

But nginx is supposed to be doing that via the uwsgi module and not me.

If you mean the built-in uwsgi support in Nginx... no, it doesn't start uwsgi for you.