Currently my docker container is printing the nginx access logs to /dev/stdout. How do I create a volume inside my docker container to store the access logs?
My Dockerfile:
FROM python:3.7
ENV APP_ROOT /src
ENV CONFIG_ROOT /config
RUN apt-get update
RUN apt-get install -y apt-utils
RUN apt-get -y install unixodbc-dev
RUN apt-get -y install default-libmysqlclient-dev
RUN mkdir ${CONFIG_ROOT}
COPY /app/requirements.txt ${CONFIG_ROOT}/requirements.txt
RUN pip install -r ${CONFIG_ROOT}/requirements.txt
RUN mkdir ${APP_ROOT}
WORKDIR ${APP_ROOT}
ADD /app/ ${APP_ROOT}
My docker-compose.yml:
version: "3"
services:
app:
build: .
container_name: django-gunicorn
restart: always
env_file:
- django.env
ports:
- "8000:8000"
command:
"gunicorn --workers=2 --bind=0.0.0.0:8000 mysite.wsgi:application"
nginx:
image: nginx:1.14
container_name: ngx
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx:/etc/nginx/conf.d
- ./app/static:/static
depends_on:
- app
My nginx/default.conf:
limit_req_zone "$binary_remote_addr$request_uri" zone=one:10m rate=60r/m;
server {
listen 80;
server_name example.org;
server_tokens off;
location /static/ {
autoindex on;
alias /static/;
}
location / {
proxy_pass http://app:8000;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
limit_req zone=one nodelay burst=30;
}
}
I am trying to add fail2ban and fluentd logging to this application but first I need to store the physical file (not /dev/stout) which can be used for other logging purposes.
Thanks you!