인프런 커뮤니티 질문&답변

liufeier님의 프로필 이미지
liufeier

작성한 질문수

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

Docker Secret을 이용한 보안

502 bad gateway가 뜹니다

작성

·

1.5K

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,

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

답변 2

0

liufeier님의 프로필 이미지
liufeier
질문자

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

0

Hyong Sok Park님의 프로필 이미지
Hyong Sok Park
지식공유자

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

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

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

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

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

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

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

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

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

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

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


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

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

liufeier님의 프로필 이미지
liufeier

작성한 질문수

질문하기