inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

작정하고 장고! Django로 Pinterest 따라만들기 : 바닥부터 배포까지

Docker Secret을 이용한 보안

502 bad gateway가 뜹니다

1668

liufeier

작성한 질문수 4

0

https://github.com/hwd3004/clone_pinterest

오라클 클라우드로 하고 있고 포트 개방은 80, 443, 8080, 8000, 9000, 3306 해주었습니다.

도커 포테이너 - 서비스에서 django_container_gunicorn이 이상한거 같습니다.

이건  django_container_gunicorn 로그입니다.

,
0 static files copied to '/home/clone_pinterest/staticfiles', 134 unmodified.,
Operations to perform:,
  Apply all migrations: accountapp, admin, articleapp, auth, commentapp, contenttypes, profileapp, projectapp, sessions, subscribeapp,
Running migrations:,
  No migrations to apply.,
  Your models in app(s): 'accountapp' have changes that are not yet reflected in a migration, and so won't be applied.,
  Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.,
[2021-06-10 09:42:42 +0000] [1] [INFO] Starting gunicorn 20.1.0,
[2021-06-10 09:42:42 +0000] [1] [ERROR] Retrying in 1 second.,
[2021-06-10 09:42:43 +0000] [1] [ERROR] Retrying in 1 second.,
[2021-06-10 09:42:44 +0000] [1] [ERROR] Retrying in 1 second.,
[2021-06-10 09:42:45 +0000] [1] [ERROR] Retrying in 1 second.,
[2021-06-10 09:42:46 +0000] [1] [ERROR] Retrying in 1 second.,
[2021-06-10 09:42:47 +0000] [1] [ERROR] Can't connect to ('0.0.0.0/8000', 8000),
,
0 static files copied to '/home/clone_pinterest/staticfiles', 134 unmodified.,
Operations to perform:,
  Apply all migrations: accountapp, admin, articleapp, auth, commentapp, contenttypes, profileapp, projectapp, sessions, subscribeapp,
Running migrations:,
  No migrations to apply.,
  Your models in app(s): 'accountapp' have changes that are not yet reflected in a migration, and so won't be applied.,
  Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.,
[2021-06-10 09:42:58 +0000] [1] [INFO] Starting gunicorn 20.1.0,
[2021-06-10 09:42:58 +0000] [1] [ERROR] Retrying in 1 second.,
[2021-06-10 09:42:59 +0000] [1] [ERROR] Retrying in 1 second.,
[2021-06-10 09:43:00 +0000] [1] [ERROR] Retrying in 1 second.,
[2021-06-10 09:43:01 +0000] [1] [ERROR] Retrying in 1 second.,
[2021-06-10 09:43:02 +0000] [1] [ERROR] Retrying in 1 second.,
[2021-06-10 09:43:03 +0000] [1] [ERROR] Can't connect to ('0.0.0.0/8000', 8000),
,
0 static files copied to '/home/clone_pinterest/staticfiles', 134 unmodified.,
Operations to perform:,
  Apply all migrations: accountapp, admin, articleapp, auth, commentapp, contenttypes, profileapp, projectapp, sessions, subscribeapp,
Running migrations:,
  No migrations to apply.,
  Your models in app(s): 'accountapp' have changes that are not yet reflected in a migration, and so won't be applied.,
  Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.,
[2021-06-10 09:43:29 +0000] [1] [INFO] Starting gunicorn 20.1.0,
[2021-06-10 09:43:29 +0000] [1] [ERROR] Retrying in 1 second.,
[2021-06-10 09:43:30 +0000] [1] [ERROR] Retrying in 1 second.,
[2021-06-10 09:43:31 +0000] [1] [ERROR] Retrying in 1 second.,
[2021-06-10 09:43:32 +0000] [1] [ERROR] Retrying in 1 second.,
,
0 static files copied to '/home/clone_pinterest/staticfiles', 134 unmodified.,
Operations to perform:,
  Apply all migrations: accountapp, admin, articleapp, auth, commentapp, contenttypes, profileapp, projectapp, sessions, subscribeapp,
Running migrations:,
  No migrations to apply.,
  Your models in app(s): 'accountapp' have changes that are not yet reflected in a migration, and so won't be applied.,
  Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.,
[2021-06-10 09:43:13 +0000] [1] [INFO] Starting gunicorn 20.1.0,
[2021-06-10 09:43:13 +0000] [1] [ERROR] Retrying in 1 second.,
[2021-06-10 09:43:14 +0000] [1] [ERROR] Retrying in 1 second.,
[2021-06-10 09:43:15 +0000] [1] [ERROR] Retrying in 1 second.,
[2021-06-10 09:43:16 +0000] [1] [ERROR] Retrying in 1 second.,
[2021-06-10 09:43:17 +0000] [1] [ERROR] Retrying in 1 second.,
[2021-06-10 09:43:18 +0000] [1] [ERROR] Can't connect to ('0.0.0.0/8000', 8000),
,
0 static files copied to '/home/clone_pinterest/staticfiles', 134 unmodified.,
Operations to perform:,
  Apply all migrations: accountapp, admin, articleapp, auth, commentapp, contenttypes, profileapp, projectapp, sessions, subscribeapp,
Running migrations:,
  No migrations to apply.,
  Your models in app(s): 'accountapp' have changes that are not yet reflected in a migration, and so won't be applied.,
  Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.,
[2021-06-10 09:42:27 +0000] [1] [INFO] Starting gunicorn 20.1.0,
[2021-06-10 09:42:27 +0000] [1] [ERROR] Retrying in 1 second.,
[2021-06-10 09:42:28 +0000] [1] [ERROR] Retrying in 1 second.,
[2021-06-10 09:42:29 +0000] [1] [ERROR] Retrying in 1 second.,
[2021-06-10 09:42:30 +0000] [1] [ERROR] Retrying in 1 second.,
[2021-06-10 09:42:31 +0000] [1] [ERROR] Retrying in 1 second.,
[2021-06-10 09:42:32 +0000] [1] [ERROR] Can't connect to ('0.0.0.0/8000', 8000),

이건 서비스 탭에 있는 nginx 로그입니다.

/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,
2021/06/10 09:30:42 [error] 34#34: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 10.0.0.2, server: , request: "GET / HTTP/1.1", upstream: "http://10.0.2.5:8000/", host: "140.83.62.96",
10.0.0.2 - - [10/Jun/2021:09:30:42 +0000] "GET / HTTP/1.1" 502 559 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36",
2021/06/10 09:30:55 [error] 34#34: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 10.0.0.2, server: , request: "GET / HTTP/1.1", upstream: "http://10.0.2.5:8000/", host: "140.83.62.96",
10.0.0.2 - - [10/Jun/2021:09:30:55 +0000] "GET / HTTP/1.1" 502 559 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36",
10.0.0.2 - - [10/Jun/2021:09:31:09 +0000] "GET / HTTP/1.1" 502 559 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36",
2021/06/10 09:31:09 [error] 34#34: *1 connect() failed (113: No route to host) while connecting to upstream, client: 10.0.0.2, server: , request: "GET / HTTP/1.1", upstream: "http://10.0.2.5:8000/", host: "140.83.62.96",
2021/06/10 09:32:03 [error] 34#34: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 10.0.0.2, server: , request: "GET / HTTP/1.1", upstream: "http://10.0.2.5:8000/", host: "140.83.62.96",
10.0.0.2 - - [10/Jun/2021:09:32:03 +0000] "GET / HTTP/1.1" 502 559 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36",
10.0.0.2 - - [10/Jun/2021:09:34:03 +0000] "GET / HTTP/1.1" 502 559 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36",
2021/06/10 09:34:03 [error] 34#34: *7 connect() failed (113: No route to host) while connecting to upstream, client: 10.0.0.2, server: , request: "GET / HTTP/1.1", upstream: "http://10.0.2.5:8000/", host: "140.83.62.96",
/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,
2021/06/10 09:30:05 [emerg] 1#1: host not found in upstream "django_container_gunicorn" in /etc/nginx/nginx.conf:21,
nginx: [emerg] host not found in upstream "django_container_gunicorn" in /etc/nginx/nginx.conf:21,
/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,
2021/06/10 09:30:21 [emerg] 1#1: host not found in upstream "django_container_gunicorn" in /etc/nginx/nginx.conf:21,
nginx: [emerg] host not found in upstream "django_container_gunicorn" in /etc/nginx/nginx.conf:21,

질문이 너무 이상해서 죄송합니다.

python django docker

답변 2

0

liufeier

아... 감사합니다. 잘되네요. 에러 메시지에도 떡하니 [2021-06-10 09:43:18 +0000] [1] [ERROR] Can't connect to ('0.0.0.0/8000', 8000), 이게 있었는데 인지를 못했네요. 부끄럽고 민망합니다..하하;;;

0

Hyong Sok Park

안녕하세요!
질문 확인했습니다.

일단 저도 처음 보는 에러네요.
확실히 gunicorn쪽에 문제가 있는 것이 맞아보입니다.

gunicorn쪽에 문제가 있으니
nginx단에서도 서버를 연결하는 데에 문제가 있는 듯 하구요.

그래서 첨부해주신 깃 저장소를 확인해보니,
Dockerfile 에서 조금 이상한 점을 확인했습니다.

마지막 CMD 를 통해 커맨드를 명시해주는 부분에서

CMD [ ... 중략 ... --bind 0.0.0.0/8000"]

이 조금 의심이 됩니다.
저희 강좌에서는 이 부분이

CMD [ ... 중략 ... --bind 0.0.0.0:8000"]

로 / 가 아닌 : 로 설정되어 있습니다.

"/" 와 같은 표기는 보통 IP 허용 영역을 지정하는,
CIDR 표기법에 사용되는 기호입니다.

저희는 포트 번호를 지정하는 것이 목적이기에,
한번 : 으로 해당 내용을 수정하신 후,
이미지를 다시 빌드하고 구동해보시길 바랍니다.


그럼에도 문제가 생기거나,
답변이 부족한 부분이 있다면 계속 질문 남겨주시길 바랍니다.

좋은하루 보내세요!
감사합니다-

강의에 나왔던 js 파일이 깃허브에 없습니다

1

79

1

모바일 디버깅, 반응형 레이아웃 4분48초 질문

0

57

1

decorator 관련질문입니다.

0

63

1

PasswordChangeView

0

104

2

로그아웃뷰 작동 관련 (2025년 3월)

1

138

1

실행에러질문

0

159

1

@login_required 데코레이터 사용시 리다이렉트는 어디서 참조하여 설정을 하는걸까요?

0

116

1

CacheBackend 관련 에러

0

181

1

21강 CreateView를 통한 회원가입 구현 질문

0

325

1

53강 disallowedhost

0

346

2

502 Bad Gateway

0

474

0

mariadb 접근권한 오류

0

545

1

logout 후 빈 화면으로 이동합니다 ㅠㅠ

0

461

2

로그아웃 후 빈 화면으로 이동

0

333

1

서버 운영 관련 질문 드립니다.(Unable to retirve...)

0

232

1

static/base.css파일을 인식을 못합니다

0

381

1

안녕하세요 19강 디버깅 설정 질문있습니다.

0

291

1

프로필 update편 질문있습니다.

0

380

1

수업질문

0

395

1

COOP error

0

531

1

61강 Dockerfile error

0

598

1

static안에 base.css 에서 정의한 클래스가 적용되지 않습니다.

0

491

1

static 파일 중 jpg 파일만 로드 불가

0

419

1

58강 static 파일 적용 안됨

0

547

1