Django + Nginx + UWSGi: истекло время ожидания восходящего потока 110 - PullRequest
0 голосов
/ 18 февраля 2019

Я развертываю приложение Django в производстве, используя Nginx и uwsgi в CentOS.

Вещи, которые я правильно настроил, как среда тестирования, но теперь я получаю 504 Gateway Time-out из моего браузера

Вот мои конфиги:

cat /etc/nginx/nginx.conf

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

include /usr/share/nginx/modules/*.conf;

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;

include /etc/nginx/conf.d/*.conf;

server {
    listen       80 default_server;
    listen       [::]:80 default_server;
    server_name  _;
    root         /usr/share/nginx/html;

    # Load configuration files for the default server block.
    include /etc/nginx/default.d/*.conf;

    location / {
        include uwsgi_params;
        uwsgi_pass 127.0.0.1:3031;
        proxy_send_timeout 1200s;
        proxy_read_timeout 1200s;
        fastcgi_send_timeout 1200s;
        fastcgi_read_timeout 1200s;
    }

    error_page 404 /404.html;
        location = /40x.html {
    }

    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }
}

}

cat /etc/nginx/conf.d/myapp.conf

# configuration of the server
upstream django {
server 192.168.56.100:3031; # for a web port socket (we'll use this first)
}

server {
    listen      80;
    server_name 192.168.56.100; # substitute your machine's IP address or FQDN
    charset     utf-8;
    access_log  /var/log/nginx/access_myapp.log ;
    error_log  /var/log/nginx/error_myapp.log ;

# max upload size
client_max_body_size 75M;   # adjust to taste

location /media/  {
    alias /usr/share/nginx/media/;  # your Django project's media files - amend as required
}

location /static/ {
    alias /usr/share/nginx/static/; # your Django project's static files - amend as required
}

location / {
    include uwsgi_params;
    uwsgi_pass 192.168.56.100:3031;
}

}

cat myapp.ini

[uwsgi]
socket = 192.168.56.100:3031
chdir = /home/vagrant/myapp
module = myapp.wsgi
processes = 4
threads = 2
stats = 127.0.0.1:9191

cat /var/log/nginx/error_myapp.log

2019/02/18 09:15:19 [error] 6090#0: *15 upstream timed out (110:  
Connection timed out) while reading response header from upstream, 
client:  192.168.56.1, server: 192.168.56.100, request: "GET / 
HTTP/1.1", upstream: "uwsgi://192.168.56.100:3031", host: 
"192.168.56.100"

Любое предложение, чтобы решить эту ошибку, пожалуйста

...