2

I try to create a socket for communication between uwsgi and nginx.

The difficulty is that I don't know what major and minor numbers I should specify:

v:/tmp# mknod wsgi_pgame.sock c
mknod: missing operand after `c'
Special files require major and minor device numbers.

And I don't know whether the device should be block or character.

Could you please help?

sergzach
  • 135
  • 1
  • 2
  • 8

1 Answers1

5

Mknod (mknod p, not c) creates a fifo, a unix socket. Unix sockets are different beasts and don't nead mknod (or root privileges for that matter). Configured properly, uwsgi will create the socket for you, you just need to make sure the permissions are right so nginx can use it. Something like this for a Debian-ish system.

shared-socket = 1
socket        = /tmp/uwsgi.sock
chmod_socket  = 600
chown_socket  = www-data
uid           = www-data
gid           = www-data
Dennis Kaarsemaker
  • 19,277
  • 2
  • 44
  • 70
  • 4
    FIFO (AKA "pipe", shown as `p` in `ls` output) is *not* the same thing as UNIX socket (shown as `=` in `ls` output). Unfortunately, you can't create UNIX socket with mknod. This is mostly for historical reasons: i.e. normally, `bind()` call expects the node to *not* exist, so creation of UNIX socket node beforehand, prior to actual connection process, make little sense. That said, if you really want to create it, most modern `netcat` / `nc` variants can do that. – GreyCat May 28 '18 at 13:42
  • Sorry, but I have to -1 for conflating a named FIFO pipe and a UNIX domain socket. They're substantially/significantly different things. See https://man7.org/linux/man-pages/man7/pipe.7.html vs https://www.man7.org/linux/man-pages/man7/unix.7.html . – mtraceur Jul 31 '23 at 00:12