Upstream timed out by django and nginx in docker-compose
У меня есть docker-compose, который имеет django и nginx
version: "3.9"
services:
admin_site:
build:
context: ./
dockerfile: Dockerfile_django.local
ports:
- "8011:8011"
restart: always
command: uwsgi --http :8010 --module admin_site.wsgi
nginx:
image: nginx:latest
container_name: nginx
volumes:
- ./nginx/conf:/etc/nginx/conf.d
- ./nginx/uwsgi_params:/etc/nginx/uwsgi_params
- ./static:/static
ports:
- '81:80'
depends_on:
- admin_site
После docker-compose up
Я могу подтвердить, что localhost:8011 работает, поэтому uwsgi работает правильно.
Однако когда я обращаюсь к localhost:81
nginx | 2022/02/18 10:07:14 [error] 24#24: *4 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 172.18.0.1, server: dockerhost, request: "GET / HTTP/1.1", upstream: "uwsgi://172.18.0.2:8011", host: "localhost:81"
nginx | 172.18.0.1 - - [18/Feb/2022:10:07:14 +0000] "GET / HTTP/1.1" 504 569 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36" "-"
происходит тайм-аут соединения.
Тест:
Я вхожу в контейнер admin_site и curl 172.18.0.2:8011 он отвечает правильно.
мой nginx.conf файл находится здесь.
upstream django {
ip_hash;
server admin_site:8011;
}
server {
listen 80;
server_name dockerhost;
charset utf-8;
location /static {
alias /static;
}
location / {
uwsgi_pass django;
include /etc/nginx/uwsgi_params;
}
}
журнал моего контейнера nginx находится здесь.
Есть ли место, которое мне нужно проверить?
nginx | /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
nginx | /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
nginx | /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
nginx | 10-listen-on-ipv6-by-default.sh: info: /etc/nginx/conf.d/default.conf is not a file or does not exist
nginx | /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
nginx | /docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
nginx | /docker-entrypoint.sh: Configuration complete; ready for start up
nginx | 2022/02/18 10:02:31 [notice] 1#1: using the "epoll" event method
nginx | 2022/02/18 10:02:31 [notice] 1#1: nginx/1.21.6
nginx | 2022/02/18 10:02:31 [notice] 1#1: built by gcc 10.2.1 20210110 (Debian 10.2.1-6)
nginx | 2022/02/18 10:02:31 [notice] 1#1: OS: Linux 5.10.76-linuxkit
nginx | 2022/02/18 10:02:31 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
nginx | 2022/02/18 10:02:31 [notice] 1#1: start worker processes
nginx | 2022/02/18 10:02:31 [notice] 1#1: start worker process 23
nginx | 2022/02/18 10:02:31 [notice] 1#1: start worker process 24
nginx | 2022/02/18 10:02:31 [notice] 1#1: start worker process 25
nginx | 2022/02/18 10:02:31 [notice] 1#1: start worker process 26
nginx | 2022/02/18 10:02:31 [notice] 1#1: start worker process 27
nginx | 2022/02/18 10:02:31 [notice] 1#1: start worker process 28
Разве этот порт не должен быть 8011?
uwsgi --http :8010 --module admin_site.wsgi