Skip to content

Commit

Permalink
add ability to add configuration by folder and not by file
Browse files Browse the repository at this point in the history
  • Loading branch information
paskal authored and umputun committed May 8, 2021
1 parent 24f1ccf commit 1a9d980
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -20,8 +20,14 @@ Simple nginx image (alpine based) with integrated [Let's Encrypt](https://letsen
- you can map multiple custom config files to in compose using `service*.conf` filename pattern,
see `service2.conf` in [docker-compose.yml](https://github.com/nginx-le/nginx-le/blob/master/docker-compose.yml)
file for reference

Alternatively, mount directory with `*.conf` files into `/etc/nginx/conf.d-le` directory inside
the container to have them all copied at once.
- `stream*.conf` files are picked up into `/etc/nginx/stream.d/` directory and included into `stream`
section of the Nginx configuration, see `stream2.conf` in `docker-compose.yml` file for reference.

Alternatively, mount directory with `*.conf` files into `/etc/nginx/conf.d-le` directory inside
the container to have them all copied at once.
- pull image - `docker-compose pull`
- if you don't want a pre-built image, make you own. `docker-compose build` will do it
- start it `docker-compose up`
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Expand Up @@ -19,6 +19,8 @@ services:
- ./etc/service-example.conf:/etc/nginx/service.conf
# - ./etc/service-example-2.conf:/etc/nginx/service2.conf # more services, should be service*.conf
# - ./etc/stream-example-2.conf:/etc/nginx/stream2.conf # more streams, should be stream*.conf
# - ./etc/conf.d:/etc/nginx/conf.d-le # configuration folder, all files from it will be added
# - ./etc/stream.conf:/etc/nginx/stream.conf.d-le # streams configuration folder, all files from it will be added
ports:
- "80:80"
- "443:443"
Expand Down
9 changes: 8 additions & 1 deletion script/entrypoint.sh
Expand Up @@ -13,7 +13,11 @@ export LE_SSL_KEY=/etc/nginx/ssl/${SSL_KEY}
export LE_SSL_CERT=/etc/nginx/ssl/${SSL_CERT}
export LE_SSL_CHAIN_CERT=/etc/nginx/ssl/${SSL_CHAIN_CERT}

#create destination folders
#create configuration source directories, in case they are not mounted
mkdir -p /etc/nginx/conf.d-le
mkdir -p /etc/nginx/stream.conf.d-le

#create destination directories
mkdir -p /etc/nginx/conf.d
mkdir -p /etc/nginx/stream.d
mkdir -p /etc/nginx/ssl
Expand All @@ -30,6 +34,9 @@ if [ ${#STREAMS_FILES} -ne 0 ]; then
cp -fv /etc/nginx/stream*.conf /etc/nginx/stream.d/
fi

cp -fv /etc/nginx/conf.d-le/*.conf /etc/nginx/conf.d/
cp -fv /etc/nginx/stream.conf.d-le/*.conf /etc/nginx/stream.conf.d/

#replace SSL_KEY, SSL_CERT and SSL_CHAIN_CERT by actual keys
sed -i "s|SSL_KEY|${LE_SSL_KEY}|g" /etc/nginx/conf.d/*.conf 2>/dev/null
sed -i "s|SSL_KEY|${LE_SSL_KEY}|g" /etc/nginx/stream.d/*.conf 2>/dev/null
Expand Down

0 comments on commit 1a9d980

Please sign in to comment.