Nginx-Uwsgi-Docker connect() to unix:/usr/src/app/uwsgi.sock failed (2: No such file or directory)

Nginx-Uwsgi-Docker connect() to unix:/usr/src/app/uwsgi.sock failed (2: No such file or directory)

Nginx return 502,因为错误:connect() to unix:/usr/src/app/uwsgi.sock failed (2: No such file or directory) 我在容器中工作。在一个 nginx 中,在另一个应用程序中。 BM 运行 在云端。容器是 运行.

输出“docker 日志 admin_nginx_1”

/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
2022/04/19 02:49:11 [crit] 32#32: *1 connect() to unix:/usr/src/app/uwsgi.sock failed (2: No such file or directory) while connecting to upstream, client: 93.94.176.50, server: 51.250.19.101, request: "GET / HTTP/1.1", upstream: "uwsgi://unix:/usr/src/app/uwsgi.sock:", host: "51.250.19.101"
51.250.19.101 93.94.176.50 - - [19/Apr/2022:02:49:11 +0000] "GET / HTTP/1.1" 502 559 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.132 YaBrowser/22.3.1.891 Yowser/2.5 Safari/537.36" 0.000
2022/04/19 02:49:12 [crit] 32#32: *1 connect() to unix:/usr/src/app/uwsgi.sock failed (2: No such file or directory) while connecting to upstream, client: 93.94.176.50, server: 51.250.19.101, request: "GET /favicon.ico HTTP/1.1", upstream: "uwsgi://unix:/usr/src/app/uwsgi.sock:", host: "51.250.19.101", referrer: "http://51.250.19.101/"
51.250.19.101 93.94.176.50 - - [19/Apr/2022:02:49:12 +0000] "GET /favicon.ico HTTP/1.1" 502 559 "http://51.250.19.101/" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.132 YaBrowser/22.3.1.891 Yowser/2.5 Safari/537.36" 0.000

输出“docker 日志 admin_web_1”

[uWSGI] getting INI configuration from /usr/src/app/config/uwsgi.ini
*** Starting uWSGI 2.0.17 (64bit) on [Tue Apr 19 03:08:22 2022] ***
compiled with version: 10.2.1 20210110 on 19 April 2022 03:04:31
os: Linux-5.4.0-96-generic #109-Ubuntu SMP Wed Jan 12 16:49:16 UTC 2022
nodename: 8ba7eda48f75
machine: x86_64
clock source: unix
detected number of CPU cores: 2
current working directory: /usr/src/app
detected binary path: /usr/local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
your memory page size is 4096 bytes
detected max file descriptor number: 1048576
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address uwsgi.sock fd 3
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
Python version: 3.9.12 (main, Apr 14 2022, 05:27:47)  [GCC 10.2.1 20210110]
Python main interpreter initialized at 0x565467430df0
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 166688 bytes (162 KB) for 2 cores
*** Operational MODE: threaded ***
WSGI app 0 (mountpoint='') ready in 2 seconds on interpreter 0x565467430df0 pid: 1 (default app)
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 1)
spawned uWSGI worker 1 (pid: 19, cores: 2)

uwsgi.ini

[uwsgi]
master = true
module = educa.wsgi:application
socket = uwsgi.sock
processe = 4
threads = 2
vacuum          = true

my_nginx.conf

# the upstream component nginx needs to connect to
upstream uwsgi {
    server unix:/usr/src/app/uwsgi.sock;
}

server {
    listen    80;
    server_name    51.250.19.101;
    client_max_body_size 6m;
    
    location / {
        uwsgi_pass  uwsgi;
        include     /etc/nginx/uwsgi_params;
    }

    location /nginx/status {
        stub_status on;
        access_log off;
        auth_basic "NginxStatus";

    }

    location /static/ {
        alias /usr/src/app/static/;
    }

    location /media/ {
        alias /usr/src/app/media/;
    }
}

文件 uwsgi.sock 存在。位于/usr/src/app/uwsgi.sock。权限:

srwxr-xr-x 1 root root    0 Apr 19 03:08 uwsgi.sock

请帮忙。

我这里没有提供docker-compose.yml。有一个错误。容器没有共享卷来一起访问套接字。 向两个容器添加卷。

在docker-compose.yml的结尾:

volumes:
    api_data:
    pgdata:

在两个容器的描述中:

        volumes:
        - api_data:/usr/src/app/