I
I
Ivan2021-12-19 00:41:26
Journaling
Ivan, 2021-12-19 00:41:26

How to make nginx custom log format in docker-compose?

like this log_format customLogFormat '$remote_addr - $remote_user [$time_local] "$request" '
'$status "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

put here in docker-compose.yml
nginx-service:
image: nginx
container_name: nginx-service
ports:
- 8000:80
environment:
- FOO=bar
logging:
driver: loki
options:
loki-url: localhost:3100/loki/api /v1/push
loki-external-labels: job=dockerlogs,owner=ruan,environment=development

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
bankinobi, 2021-12-19
@bankinobi

In docker-compose.yaml add volume with nginx config

volumes:
                    - ./nginx.conf:/etc/nginx/nginx.conf

And write your log_format in the config

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question