webdevops / Dockerfile

:package: Dockerfiles from WebDevOps for PHP, Apache and Nginx
https://webdevops.io/projects/dockerfiles/
MIT License
1.66k stars 492 forks source link

[Question] How to change nginx worker_connections / log format of webdevops/php-nginx image #399

Closed stefanheimann closed 3 years ago

stefanheimann commented 3 years ago

Hy!

I've two questions, were i struggle to find a solution, maybe somebody can help me with that. is there an easy way to change worker_connections and log format of nginx config? I didn't find one.

I want to bump worker_connections to 1024 and change log format to:

log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                  '$status $body_bytes_sent "$http_referer" '
                  '"$http_user_agent" "$http_x_forwarded_for"';

best approach I could come up so far was to run the container, grab content of /etc/nginx/nginx.conf and copy/paste it to a local file, which then overrides the file within the container.

htuscher commented 3 years ago

The customization is done by copying files into the right directories during build time of your image.

FROM webdevops/php-nginx:7.4
COPY ./some-nginx.conf /opt/docker/etc/nginx/conf.d/

As described here: https://dockerfile.readthedocs.io/en/latest/content/DockerImages/dockerfiles/php-nginx.html#nginx-customization

In your conf file you can configure the log_format to your needs.