This project enables automation in exposing Docker containers via NGINX. In particular, it:
- parses JSON configurations and create conf files
- creates a NGINX instance with mounted folders
- generates basic authentication file
- exposes basic admin via the
manage.sh
file
usage manage.sh [clean_conf | gen_default | gen_all | start | restart | reload | stop]
options:
- clean_conf: removes all the configuration from
nginx/conf.d/
- gen_default: generates only the
default.conf
file - gen_all: generates all the configurations files from the
nginx_conf.json
file - start: starts the docker container of nginx
- restart: restarts the docker container
- reload: reloads the configuration in
nginx/conf.d/
- stop: stops the container and clean the current folder
The python script nginxify.py
can be used to generate *.conf
files.
./nginxify.py --help
usage: nginxify.py [-h] [--default ONLY_DEFAULT] [--dest DEST_FOLDER]
[--conf CONFS_FILE] [--overwrite OVERWRITE]
nginx conf generator
optional arguments:
-h, --help show this help message and exit
--default ONLY_DEFAULT
if true generate only the default configurations
--dest DEST_FOLDER The folder to save the *.conf files. Default value
'./nginx/conf.d/'
--conf CONFS_FILE The json file with the configurations. Default value
'nginx_conf.json'
--overwrite OVERWRITE
True to overwrite all the configurations files
The file contains a list of proxies
with:
- name: the name of the proxy
- server_names: the name of the domain name to expose the service
- docker_name: the name or ip address of the docker container to expose
- docker_port: the internal port of the container
- secured: if the service should be secured with nginx auth_basic
{
"proxies": [
{
"name": "spark",
"servers": [
"spark.datatoknowledge.it"
],
"dockers": [
"spark-master-0:8080"
],
"secured": true
},
{
"name": "es",
"servers": [
"es.datatoknowledge.it"
],
"dockers": [
"es-data-0:9200",
"es-data-1:9200",
"es-data-1:9200"
],
"docker_name": "es-data-0",
"docker_port": "9200",
"secured": true
},
{
"name": "datatoknowledge",
"servers": [
"datatoknowledge.it",
"www.datatoknowledge.it"
],
"dockers": [
"dtk-0:5000"
],
"secured": false
}
]
}
The script password_generator.py
can be used to generate a file that stores the access passwords. By default it stores all the password in /nginx/htpasswd/secure
. This file is mapped to the running docker container.
./password_generator.py --help
usage: password_generator.py [-h] [--file DEST_FOLDER] [--user USER]
[--pwd PWD]
nginx auth file generator
optional arguments:
-h, --help show this help message and exit
--file DEST_FOLDER the folder to save the new username:password pair
--user USER the username for the new user
--pwd PWD the password for the new user
As default there is a custom_404 custom_50x and index page in the folder ./nginx/www/html
. If you need you can change these pages.
- To generate NGINX conf via json configuration file
- To start an NGINX instance via dockr-compose
- To generate basic authentications
- To generate json file from docker inspection
- To generate json file from weave inspection
- To implement web admin gui