Nginx workflow freezes and takes up a full processor

I have setup with Nginx, uWSGI and Python Flask. Below you can find the server directive from the Nginx configuration:

location /api { try_files $uri @api; } location @api { include uwsgi_params; uwsgi_pass 127.0.0.1:3031; } 

I am running uWSGI with uwsgi --ini /etc/uwsgi.ini . This file is as follows:

 [uwsgi] uid = root gid = root socket = 127.0.0.1:3031 module = iris.api callable = app 

Requests / work fine, Nginx returns a "Welcome to Nginx" page. But the request /api not executed. The first request in /api/analog_output/1 is passed through uWSGI to the Python application. The Python application returns with an HTTP 200 response, but Nginx does not complete the request by sending this response to the client.

 --- Operational MODE: single process --- WSGI app 0 (mountpoint='') ready in 11 seconds on interpreter 0x1567e8 pid: 957 (default app) --- uWSGI is running in multiple interpreter mode --- spawned uWSGI worker 1 (and the only) (pid: 957, cores: 1) [pid: 957|app: 0|req: 1/1] 10.0.0.125 () {42 vars in 712 bytes} [Sun Jan 14 17:22:49 2007] GET /api/analog_output/1 => generated 135 bytes in 66 msecs (HTTP/1.1 200) 2 headers in 72 bytes (1 switches on core 0) 

Below you can find the result of strace binding to working Nginx.

 17:27:39.127453 gettimeofday({1168795659, 128279}, NULL) = 0 17:27:39.129180 write(4, "2007/01/14 17:27:39 [info] 970#0"..., 83) = 83 17:27:39.130169 epoll_wait(8, {{EPOLLIN, {u32=651592, u64=2410198208213320}}}, 512, -1) = 1 17:27:44.680001 gettimeofday({1168795664, 680353}, NULL) = 0 17:27:44.682734 accept4(6, {sa_family=AF_INET, sin_port=htons(53845), sin_addr=inet_addr("10.0.0.125")}, [16], SOCK_NONBLOCK) = 3 17:27:44.685625 epoll_ctl(8, EPOLL_CTL_ADD, 3, {EPOLLIN|EPOLLRDHUP|EPOLLET, {u32=651816, u64=651816}}) = 0 17:27:44.688045 epoll_wait(8, {{EPOLLIN, {u32=651816, u64=651816}}}, 512, 60000) = 1 17:27:44.690552 gettimeofday({1168795664, 691682}, NULL) = 0 17:27:44.693043 recv(3, "GET /api/analog_output/1 HTTP/1."..., 1024, 0) = 426 17:27:44.695848 stat64("/usr/html/api/analog_output/1", 0xbeb8f730) = -1 ENOENT (No such file or directory) 17:27:44.698599 epoll_ctl(8, EPOLL_CTL_MOD, 3, {EPOLLIN|EPOLLOUT|EPOLLRDHUP|EPOLLET, {u32=651816, u64=13170497834292212264}}) = 0 17:27:44.701146 getsockname(3, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("10.0.0.195")}, [16]) = 0 17:27:44.703848 socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 10 17:27:44.706386 ioctl(10, FIONBIO, [1]) = 0 17:27:44.708823 epoll_ctl(8, EPOLL_CTL_ADD, 10, {EPOLLIN|EPOLLOUT|EPOLLRDHUP|EPOLLET, {u32=651928, u64=2525337691484824}}) = 0 17:27:44.711468 connect(10, {sa_family=AF_INET, sin_port=htons(3031), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EINPROGRESS (Operation now in progress) 17:27:44.714574 epoll_wait(8, {{EPOLLOUT, {u32=651816, u64=13170497834292212264}}, {EPOLLOUT, {u32=651928, u64=2525337691484824}}}, 512, 60000) = 2 17:27:44.717109 gettimeofday({1168795664, 718064}, NULL) = 0 17:27:44.719461 recv(3, 0xbeb8f89c, 1, MSG_PEEK) = -1 EAGAIN (Resource temporarily unavailable) 17:27:44.721999 getsockopt(10, SOL_SOCKET, SO_ERROR, [0], [4]) = 0 17:27:44.724476 writev(10, [{"\0\310\2\0\f\0QUERY_STRING\0\0\16\0REQUEST_ME"..., 716}], 1) = 716 17:27:44.729618 epoll_wait(8, {{EPOLLIN|EPOLLOUT, {u32=651928, u64=2525337691484824}}}, 512, 60000) = 1 17:27:44.793473 gettimeofday({1168795664, 794585}, NULL) = 0 17:27:44.796026 recv(10, "HTTP/1.1 200 OK\r\nContent-Type: a"..., 4096, 0) = 207 

But now working Nginx hangs with a full processor. Further requests are not processed.

What's happening? And how can I fix this?

+5
source share
1 answer

Your location block does not look complete. Not in front of the machine at the moment, but try adding:

proxy_redirect off;

edit: location block @app

0
source

All Articles