Acted on manuals https://gist.github.com/evildmp/3094281 and https://habrahabr.ru/post/226419/ .

user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid; events { worker_connections 1024; } http { log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; # Load modular configuration files from the /etc/nginx/conf.d directory. # See http://nginx.org/en/docs/ngx_core_module.html#include # for more information. include /etc/nginx/conf.d/*.conf; upstream django { server unix:///tmp/site.sock; } server { listen 80; server_name XXXX; charset utf-8; location / { uwsgi_pass django; include /var/www/site/uwsgi_params; } } } 

from under the user I launch uwsgi:

 $ uwsgi --socket /tmp/site.sock --chdir /var/www/site --module site.wsgi --chmod-socket=777 $ ls -l /tmp/site.sock srwxrwxrwx. 1 user user 0 апр 20 12:23 /tmp/site.sock 

however, nginx when trying to access the page gives 502 and in the log:

[crit] 15145 # 0: * 3 connect () to unix: ///tmp/site.sock failed (2: No such file or directory) while connecting to upstream, client: XXXX, server: XXXX, request: "GET / Http / 1.1 ", upstream:" uwsgi: // unix: ///tmp/site.sock: ", host:" XXXX "

If I try to listen not to a socket, but to a port, then I get:

15230 # 0: * 1 connect () to XXXX: 8000 failed (13: Permission denied) while connecting to upstream, client: XXXX, server: XXXX, request: "GET / HTTP / 1.1", upstream: "uwsgi: // XXXX: 8000 ", host:" XXXX "

What can be wrong?

  • unix:///tmp/site.sock there really should be three slashes? judging by the documentation, one is enough - nörbörnën
  • The same "connect () to unix: /tmp/site.sock failed (2: No such file or directory)", if that is centos7. - user3664363
  • If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Nicolas Chabanovsky

1 answer 1

server unix: ///tmp/site.sock;

see, for example, this answer: https://serverfault.com/a/464025/292034

short summary:

place socket not in /tmp , but in /var/run .


and, yes, one slash is more than enough:

 server unix:/var/run/something; 

 uwsgi --socket /var/run/something ...