U
U
user.2021-08-19 19:26:09
Nginx
user., 2021-08-19 19:26:09

How is it easier and more competent to connect your nginx.conf inside the container?

Good afternoon,

there is a docker image of a simple nginx based reverse proxy server that I successfully use in my docker-compose.yml.

proxy:
    container_name: nginx-proxy
    restart: always
    image: jwilder/nginx-proxy
    ports:
      - 80:80
      - 443:443
    volumes:
      - certs:/etc/nginx/certs
      - vhost.d:/etc/nginx/vhost.d
      - html:/usr/share/nginx/html
      - /var/run/docker.sock:/tmp/docker.sock
    environment:
      - DEFAULT_HOST=site.ru
    networks:
      - main_network


In this container, I need to add only one line to nginx.conf, since it 'does not pass' a file larger than a certain size to my services that are behind it ...

Actually, how is it easier to do this?
add volume?
Maybe after the start just replace this config in the container?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Sokolov, 2021-08-19
@nekolov

The documentation says that it is enough to create a file *.confand put it in /etc/nginx/conf.d/a container.
You can build your image with such a modification, for example:

FROM nginx-proxy/nginx-proxy
RUN { \
      echo 'server_tokens off;'; \
      echo 'client_max_body_size 500m;'; \
    } > /etc/nginx/conf.d/my_proxy.conf

A
Alexander Karabanov, 2021-08-19
@karabanov

Add volume
Or add the whole /etc/nginx/ as a volume and remove the others

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question