This repository hosts utiltiy to generate a valid Nginx Configuration from the specified input params
The project aims to create a valid Nginx configuration from a generalized yaml template provided as input.
The project is divided into the following folders , files
nginx
:- This folder hosts the backing library file which generates the valid Nginx Configuration .requirements.txt
:- Standard pythonic way to store the dependencies used in the project.resources
:- This folder hosts a sample input yaml for the project , and this is the default directory where generated output nginx configs are stored if ouput file path is not specified.resouces/sample_input.yaml
:- Sample yaml input file for reference.resources/sample_generated_nginx.conf
:- Sample Nginx configuration that would be generated for sample input.yaml file.nginx_config_generator.py
:- Driver script which builds configuration for Nginx.tests.py
:- Unit test file hosts tests around nginx configuration.
Running the script is quite easy , make sure the pre-requisite dependencies are installed ( as listed in requirements.txt)
pip3 install requirementts.txt
Run the script with the following command line params
nginx_config_generator.py --input <input_yaml_file> --output <output_config_file_path>
For getting help on the script and params, run the driver script with --help
argument
nginx_config_generator.py --help
usage: nginx_config_generator.py [-h] --input INPUT [--output OUTPUT]
Script to generate Nginx Configuration
optional arguments:
-h, --help show this help message and exit
--input INPUT Location of the input.yaml file to process
--output OUTPUT Location where the output nginx donfig would be dumped
(this includes the output file name as well
- --input argument is mandatory to be provided for the script to run.
- --output argument is optional, if not specified the generated Nginx configuration would be created under resources folder.
- Subsequent run of the script would over-ride the already generated Nginx configuration if the explicity default path is not provided.