Sock failed (111: Connection refused) при подключении к upstream с использованием nginx + uwsgi для django

Я делаю сервер django. Сервер использует nginx и uwsgi.

При тестировании производительности сервера произошла следующая ошибка.

2021/10/07 02:23:03 [error] 31#31: *9168 connect() to unix:/run/uwsgi/xxxx.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: xx.xxx.xxx.xx, server: xxxx.xxx.com, request: "GET /xxxx HTTP/1.1", upstream: "uwsgi://unix:/run/uwsgi/xxxx.sock:", host: "xxxx.xxx.com"

.

Я провел небольшое исследование этой проблемы и обнаружил, что можно просто отрегулировать размер очереди сокетов uwsgi. ( Ресурс временно недоступен при использовании uwsgi + nginx))

Однако, если я добавляю опцию listen в конфигурацию uwsgi, я получаю следующую ошибку:

2021/10/19 06:34:16 [error] 31#31: *69 connect() to unix:/run/uwsgi/xxxx.sock failed (111: Connection refused) while connecting to upstream, client: xx.xxx.xxx.xxx, server: xxxx.xxx.com, request: "GET /health-check HTTP/1.1", upstream: "uwsgi://unix:/run/uwsgi/xxxx.sock:", host: "xx.xxx.xxx.xxx"

.

Пробовал много способов решить эту проблему, но ничего не получилось.

Мне нужна помощь. Вот мои конфигурации nginx, uwsgi и т.д.

uwsgi.ini

[uwsgi]
project = xxxx
project_root = /xxxx
wsgi_path = xxxx_server_site
 
chdir = %(project_root)
module = %(wsgi_path).wsgi:application
 
master = true
processses = 4
listen = 4096 # Problem occurred after adding this option. If removed, it works normally.
 
socket = /run/uwsgi/%(project).sock
chmod-socket = 666
vacuum = true
 
logto = /var/log/uwsgi/%(project).log

/etc/nginx/conf.d/default.conf

server {
    listen 80;
    server_name xxxx.xxx.com;
 
    location / {
        include uwsgi_params;
        uwsgi_pass unix:/run/uwsgi/xxxx.sock;
        limit_except GET PUT { deny all; }
    }
}

/etc/nginx/nginx.conf

user    nginx;
worker_processes    auto;

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

events {
    worker_connections  4096;
}

http {
    include         /etc/nginx/mime.types;
    default_type    application/octet-stream;

    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;

    keepalive_timeout   65;
    
    #gzip   on;

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

docker-compose.yml

version: '3'
services:
    nginx:
        container_name: nginx
        build: ./nginx
        image: %{registry url}-%{nginx image name}
        restart: always
        ports:
          - "80:80"
        depends_on:
          - app
        volumes:
          - socket_share:/run/uwsgi
          - ./volumes/logs/nginx:/var/log/nginx
    app:
        container_name: app
        build: ./xxxx_app
        image: %{registry url}-%{app image name}
        restart: always
        command: uwsgi --ini uwsgi.ini
        volumes:
          - socket_share:/run/uwsgi
volumes:
    socket_share:

Кто-нибудь знает, как решить эту проблему? Пожалуйста.

Вернуться на верх