Nginx return 502, because error: connect() to unix:/usr/src/app/uwsgi.sock failed (2: No such file or directory) I work in containers. In one nginx, in another application. BM run in cloud. Containers is run.
Output "docker logs 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
Output "docker logs 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/;
}
}
File uwsgi.sock exists. Is located /usr/src/app/uwsgi.sock. Permission:
srwxr-xr-x 1 root root 0 Apr 19 03:08 uwsgi.sock
Please help.
CodePudding user response:
I have't provided docker-compose.yml here. There was a mistake. The containers did't have a shared volume to access the socket together. Added volumes to both containers.
At the end of docker-compose.yml:
volumes:
api_data:
pgdata:
In the description of both containers:
volumes:
- api_data:/usr/src/app/