docker-compose.yml
nginx:
volumes:
- ./nginx:/etc/nginx/conf.d (로컬의 nginx 설정파일 위치: 도커 내부의 nginx 파일 위치)
- ./project_name/collected_statics:/staticfiles (로컬의 static 파일 위치:도커의 static 파일 위치)
로컬의 nginx 폴더에 있는 default.conf
---default.conf
server {
client_max_body_size 16M;
# static 파일을 제공해야할 경우
location /static/ { # url에 /static 요청 온 경우
alias /staticfiles/; # nginx 컨테이너 내에서 django static 파일 갖고 있는 디렉토리
}
# media 파일 제공
#location /media/ {
# autoindex on;
# alias /code/media/;
#}
# 프록시 설정, nginx 뒤에 WAS가 있을 경우
location / {
proxy_pass http://django/;
}
# 포트 설정
listen 80;
server_name localhost;
}