nginx错误:worker_connections不够达芙妮Django渠道主管

时间:2019-02-25 16:49:16

标签: django nginx supervisord django-channels

我有一个使用Django Channels v2的Django 2.1应用程序,该程序在daphne,nginx和超级用户上运行。

我已经遍历所有SO论坛并尝试了所有正确答案(例如将localhost更改为127.0.0.1,将proxy_pass的值更改为myapp.com,但是无法解决此错误。

sudo less /var/log/nginx/error.log显示

2019/02/25 16:31:08 [alert] 7154#7154: *13731 768 worker_connections are not enough while connecting to upstream, client: 127.0.0.1:8000, server: myapp.com, request: "GET / HTTP/1.1", upstream: "http:/127.0.0.1:8000/", host: "www.myapp.com"

我尝试增加worker_connections,但得到一个  connection refused too many循环。

我的服务器块位于/etc/nginx/sites-available/myapp

upstream channels-backend {
    server 127.0.0.1:8000;
}

server {
    listen 127.0.0.1:8000;
    server_name myapp.com www.myapp.com;

    location = /favicon.ico { access_log off; log_not_found off; }

    location / {
        try_files $uri @proxy_to_app;
    }

    location /static/ {
        root /home/user/myapp/src/myapp;
    }

    location /media/  {
        root /home/user/myapp/src/myapp;
        include /etc/nginx/mime.types;
    }

    location @proxy_to_app {
        proxy_pass http://channels-backend;

        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";

        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Host $server_name;
}

我的主管配置文件

[fcgi-program:asgi]
# TCP socket used by Nginx backend upstream
socket=tcp://127.0.0.1:8000

# Directory where your site's project files are located
directory=/home/user/myapp/src/myapp

# Each process needs to have a separate socket file, so we use process_num
# Make sure to update "mysite.asgi" to match your project name
command=daphne -u home/user/daphne/run/daphne%(process_num)d.sock --fd 0 --access-log - --prox$

# Number of processes to startup, roughly the number of CPUs you have
numprocs=4

# Give each process a unique name so they can be told apart
process_name=asgi%(process_num)d

# Automatically start and recover processes
autostart=true
autorestart=true

# Choose where you want your log to go
stdout_logfile=/home/user/daphne/logs/asgi.log
redirect_stderr=true

运行sudo journalctl -u nginx给出

Feb 25 xxx myapp systemd[1]: Started A high performance web server and a reverse proxy server.

0 个答案:

没有答案