Q&A

책을 따라하다가 막히는 부분이 있나요?
질문을 남겨주세요.

nginx 오류

3 years, 6 months ago

why why

nginx_1  | nginx: [emerg] host not found in upstream "perfume_django" in /etc/nginx/conf.d/nginx.conf:8


위와 같은 오류가 발생하면서 실행이 안되는것 같아요

docker-compose.yml

version: '3'

services:
nginx:
build: ./nginx
volumes:
- static_volume:/usr/src/app/_static
- media_volume:/usr/src/app/media
ports:
- 80:80
depends_on:
- web
web:
build: .
#command: python manage.py runserver 0.0.0.0:8000
command: gunicorn perfume.wsgi:application --bind 0.0.0.0:8000
volumes:
- static_volume:/usr/src/app/_static
- media_volume:/usr/src/app/media
- ./:/usr/src/app/
expose:
- 8000
env_file:
- ./.env.prod
depends_on:
- db
db:
image: postgres:12.0-alpine
volumes:
- postgres_data:/var/lib/postgresql/data/
env_file:
- ./.env.prod.db
volumes:
postgres_data:
static_volume:
media_volume:


nginx.conf

upstream perfume_django {
server web:8000;
}
server {
listen 80;
location / {
proxy_pass http://perfume_django;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
}

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

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


혹시 잘못된 부분이 있나요??ㅠ


why
why   3 years, 6 months ago

전체 오류는 다음과 같습니다 ㅜㅜ


(venv) C:\Users\pbd28\PycharmProjects\perfume>docker-compose up

Docker Compose is now in the Docker CLI, try `docker compose up`


Creating network "perfume_default" with the default driver

Creating perfume_db_1 ... done

Creating perfume_web_1 ... done

Creating perfume_nginx_1 ... done

Attaching to perfume_db_1, perfume_web_1, perfume_nginx_1

db_1     | 2021-04-20 02:06:22.299 UTC [1] LOG:  starting PostgreSQL 12.0 on x86_64-pc-linux-musl, compiled by gcc (Alpine 8.3.0) 8.3.0, 64-bit

db_1     | 2021-04-20 02:06:22.299 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432

db_1     | 2021-04-20 02:06:22.300 UTC [1] LOG:  listening on IPv6 address "::", port 5432

db_1     | 2021-04-20 02:06:22.307 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"

db_1     | 2021-04-20 02:06:22.324 UTC [19] LOG:  database system was shut down at 2021-04-20 02:05:43 UTC

db_1     | 2021-04-20 02:06:22.327 UTC [1] LOG:  database system is ready to accept connections

nginx_1  | /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration

nginx_1  | /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/

nginx_1  | /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh

nginx_1  | 10-listen-on-ipv6-by-default.sh: info: /etc/nginx/conf.d/default.conf is not a file or does not exist

nginx_1  | /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh

nginx_1  | /docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh

nginx_1  | /docker-entrypoint.sh: Configuration complete; ready for start up

web_1    | [2021-04-20 02:06:23 +0000] [1] [INFO] Starting gunicorn 20.1.0

web_1    | [2021-04-20 02:06:23 +0000] [1] [INFO] Listening at: http://0.0.0.0:8000 (1)

web_1    | [2021-04-20 02:06:23 +0000] [1] [INFO] Using worker: sync

web_1    | [2021-04-20 02:06:23 +0000] [8] [INFO] Booting worker with pid: 8

nginx_1  | 2021/04/20 02:06:23 [emerg] 1#1: host not found in upstream "perfume_django" in /etc/nginx/conf.d/nginx.conf:8

nginx_1  | nginx: [emerg] host not found in upstream "perfume_django" in /etc/nginx/conf.d/nginx.conf:8

perfume_nginx_1 exited with code 1

Updated: April 20, 2021, 11:09 a.m.

why
why   3 years, 6 months ago

build를 진행하고 나니깐 오류가 해결되었습니다.

Updated: April 20, 2021, 1:49 p.m.

taegon
taegon   3 years, 6 months ago

답변이 늦었습니다.

해결이 잘 되셨다니 다행입니다. nginx.conf 파일은 도커파일에서 이미지에 복사해넣는 방식으로 소개해드렸습니다. 이미지를 다시 빌드하지 않으면, 현재 폴더에서 변경한 파일이 nginx 컨테이너에 들어가지 않기 때문에, 이전 파일로 인스턴스를 띄우게 됩니다.

빌드 하신 이후에, 수정된 파일이 정상적으로 반영이 되어 오류가 해결된 것 같습니다.

Updated: May 3, 2021, 11:22 a.m.

Leave a Comment:
목록보기
Search
  • 자유게시판
  • Q&A