1

Application is fine, because if i run it from manage.py(runserver) - everything works (responces on GET requests).. Configuration :

  • nginx 1.4.2
  • python 2.7.3
  • django 1.5.4
  • uwsgi 1.9
  • OS - debian

uwsgi yaml config:

uwsgi:
  chdir: /var/projects/HOA_desk
  module: HOA_desk.wsgi:application
  env: DJANGO_SETTINGS_MODULE=HOA_desk.settings
  socket: /tmp/HOA_desk.sock
  master: 1
  pidfile: /tmp/HOA_desk.pid
  no-orphans: 1
  processes: 2
  max-requests: 5000
  buffer-size: 32768
  harakiri: 30
  reload-mercy: 8
  vacuum: 1
  daemonize: /var/projects/HOA_desk.log
  touch-reload: /var/projects/HOA_desk/hoa_desk_uwsgi.yaml
  stats: 127.0.0.1:9191
  virtualenv: /var/projects/projects_ve/HOA_desk_ve/

nginx.conf

user www-data;
worker_processes  1;

error_log  /var/log/nginx/error.log;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include     mime.types;

    access_log  /var/log/nginx/access.log;

    sendfile        on;

    keepalive_timeout  65;
    tcp_nodelay        on;

    gzip  on;
    gzip_disable "MSIE [1-6]\.(?!.*SV1)";

    include sites-enabled/*;
}

nginx application config:

upstream HOA_desk_django {
    server unix:///tmp/HOA_desk.sock;
}

server {
    client_max_body_size 15M;
    listen 80;
    server_name xx.xx-xxxx.xx;
    charset utf-8;
    gzip on;
    expires off;
    access_log /var/projects/HOA_desk_nginx_access.log;
    error_log /var/projects/HOA_desk_nginx_error.log debug;

    location / {
        root /var/projects/HOA_desk;
        uwsgi_pass HOA_desk_django;
        include    uwsgi_params;
    }

    location /static/ {
        add_header X-Static hit;
        autoindex on;
        expires off;
        root /var/projects/HOA_desk/;
    }

    location /uploads/ {
            autoindex on;
            root /var/projects/HOA_desk/;
    }
}

uwsgi_params:

uwsgi_param  QUERY_STRING       $query_string;
uwsgi_param  REQUEST_METHOD     $request_method;
uwsgi_param  CONTENT_TYPE       $content_type;
uwsgi_param  CONTENT_LENGTH     $content_length;

uwsgi_param  REQUEST_URI        $request_uri;
uwsgi_param  PATH_INFO          $document_uri;
uwsgi_param  DOCUMENT_ROOT      $document_root;
uwsgi_param  SERVER_PROTOCOL    $server_protocol;

uwsgi_param  REMOTE_ADDR        $remote_addr;
uwsgi_param  REMOTE_PORT        $remote_port;
uwsgi_param  SERVER_ADDR        $server_addr;
uwsgi_param  SERVER_PORT        $server_port;
uwsgi_param  SERVER_NAME        $server_name;

I launch uwsgi like : uwsgi --uid 33 --gid 33 -y %config_file% Nginx : nginx -c /etc/nginx/nginx.conf

And logs output:

uwsgi :

** Starting uWSGI 1.9.16 (64bit) on [Tue Sep 17 14:31:51 2013] ***
compiled with version: 4.4.5 on 17 September 2013 12:35:39
os: Linux-2.6.26-2-xen-amd64 #1 SMP Thu Nov 25 06:39:26 UTC 2010
nodename: dstestvoip
machine: x86_64
clock source: unix
detected number of CPU cores: 1
current working directory: /var/projects
writing pidfile to /tmp/HOA_desk.pid
detected binary path: /var/projects/projects_ve/HOA_desk_ve/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
uWSGI running as root, you can use --uid/--gid/--chroot options
setgid() to 33
setuid() to 33
your memory page size is 4096 bytes
 *** WARNING: you have enabled harakiri without post buffering. Slow upload could be     rejected on post-unbuffered webservers ***
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 /tmp/HOA_desk.sock fd 3
Python version: 2.7.3 (default, Nov 19 2012, 09:51:09)  [GCC 4.4.5]
Set PythonHome to /var/projects/projects_ve/HOA_desk_ve/
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x8f6830
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 304392 bytes (297 KB) for 2 cores
*** Operational MODE: preforking ***
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x8f6830 pid: 19656 (default     app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 19656)
spawned uWSGI worker 1 (pid: 19657, cores: 1)
spawned uWSGI worker 2 (pid: 19658, cores: 1)
*** Stats server enabled on 127.0.0.1:9191 fd: 11 ***

And then try go get index page ( location / ), and.. nginx access and error log output :

error log :

2013/09/17 14:17:14 [alert] 19574#0: accept4() failed (38: Function not implemented)
2013/09/17 14:17:31 [info] 19574#0: *2 client closed connection while waiting for request,     client: 77.41.15.118, server: 0.0.0.0:80
2013/09/17 14:17:31 [info] 19574#0: *3 client closed connection while waiting for request,     client: 77.41.15.118, server: 0.0.0.0:80
2013/09/17 14:17:31 [info] 19574#0: *4 client closed connection while waiting for request, client: 77.41.15.118, server: 0.0.0.0:80
2013/09/17 14:17:31 [info] 19574#0: *5 client closed connection while waiting for request, client: 77.41.15.118, server: 0.0.0.0:80
2013/09/17 14:17:31 [info] 19574#0: *6 client closed connection while waiting for request, client: 77.41.15.118, server: 0.0.0.0:80
2013/09/17 14:18:14 [error] 19574#0: *1 upstream timed out (110: Connection timed out)     while reading response header from upstream, client: 77.41.15.118, server: xx.xxx-xxxxx.xx,     request: "GET / HTTP/1.1$

Access log:

77.41.15.118 - - [17/Sep/2013:14:18:14 +0400] "GET / HTTP/1.1" 504 584 "-" "Mozilla/5.0     (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.65     Safari/537.36"

I tried to use simple socket(not file-socket) - all was the same. What wrong in this config files, something wrong with uwsgi settings or nginx-uwsgi_socket mapping??

6
  • I know it's not helpful. But have you considered ditching uWSGI in favour of Gunicorn? Gunicorn is easier to debug: HTTP vs custom binary (!) protocol. Also, have you checked permissions to socket file?
    – ash
    Sep 17, 2013 at 10:57
  • I will think about gUnicorn later, but i need to solve this problem. But if we talking about socket file permissions - they are ok, and also - i used tried to configure this stack with simple socket(not socket file) and everything was the same. Sep 17, 2013 at 11:07
  • In this case uWSGI even doesn't accept connection. There is no response from uWSGI at all.
    – VBart
    Sep 17, 2013 at 12:44
  • @ash wow there are still people not knowing that uWSGI can speak HTTP, FastCGI, SCGI and ZeroMQ :) the uwsgi protocol is an optimization, not the rule
    – roberto
    Sep 17, 2013 at 13:57
  • @roberto Thank you, I didn't know it. But configuration in question uses uwsgi protocol, doesn't it? If it does, then the protocols you mention are of no use when debugging nginx <-> uWSGI interaction.
    – ash
    Sep 17, 2013 at 14:23

1 Answer 1

2

The problem is with your kernel not supporting accept4() syscall while nginx is compiled to use it (and even uWSGI will use it if your headers exposes it). Which kernel are you using ? Very probably it is too old in respect to your system headers

4
  • 2
    If nginx is failed to use accept4() it switches to plain accept() without problems. Not sure about uWSGI. But indeed, 2.6.26 is ancient, and @Andrewshkovskii should upgrade the system ASAP.
    – VBart
    Sep 17, 2013 at 14:39
  • uWSGI does not fallback, but if it is the problem you can build uWSGI for older kernel: CFLAGS="-DOBSOLETE_LINUX_KERNEL" make
    – roberto
    Sep 17, 2013 at 15:49
  • Going to update kernel today, will post result later. Thank you for thoughts. Sep 18, 2013 at 5:57
  • I'm on a virtual server using linux kernel 2.6.9 and I've build nginx, uwsgi, as well as lots of dependencies and got them all working, except for this issue - i've re-compiled uwsgi with the -DOBSOLETE_LINUX_KERNEL flag and it nginx still times out waiting for a response from uwsgi, but the uwsgi log shows it produced an output and in less than a second. Are there any other ideas to help me? Thanks for any assistance! Feb 19, 2014 at 7:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.