nginx-configurator/README.md

71 lines
2.2 KiB
Markdown
Raw Normal View History

2023-11-05 14:47:28 +01:00
# Nginx cluster configurator - ncc
2024-11-04 22:38:57 +01:00
Quality of life script for nginx and dehydrated.
2023-11-05 14:47:28 +01:00
## Features
* Allows the editing of services and using a template for new ones. Makes sure
the configuration is valid before reloading the cluster (nginx).
* Automatically obtains SSL certificates and replicates them to the cluster (dehydrated).
* Will only make changes on the master server (keepalived).
2023-10-25 19:37:39 +02:00
2023-10-25 19:38:52 +02:00
# TODO
2023-11-05 14:47:28 +01:00
2023-10-26 15:55:27 +02:00
* Prepare config templates for nginx and dehydrated?
* document dhparam.pem generation (`openssl dhparam -out ssl-dhparams.pem 4096` in /etc/autossl)
* Limit current SSH keys to only config rsync and nginx reload
* Write down how it works in human language
* Create a guide how to use it to intrawiki
* Teach everybody how to use it...
2023-11-05 14:47:28 +01:00
# Installation
2023-10-26 15:55:27 +02:00
2024-11-04 22:38:57 +01:00
* Install dependencies: nginx, keepalived (optional i guess), rsync, ssh, python3
* Install `ncc` through pip (or pipx) from this git repository
* Create a `ncc.yml` file (see `ncc.yml.sample`)
* Create a base nginx config (in `conf_dir`):
It should look like this:
```
conf/
nginx.conf
sites/
...
dehydrated/
dehydrated.sh <= you need to download dehydrated from github.com/dehydrated-io/dehydrated
config <= you don't have to configure anything, i recommend using AUTO_CLEANUP=yes
...
```
* Register to CA with dehydrated (`./dehydrated.sh --register --accept-terms`)
* Optional (for `new` command): Create a `templates` folder inside `conf_dir` and create some templates.
* Deploy once with a valid configuration (like a default http server that will
serve `/var/www/dehydrated`), so that dehydrated will be able to deploy
challenges.
* Done.
2023-10-26 15:55:27 +02:00
2023-11-05 14:47:28 +01:00
# Usage
2023-10-26 15:55:27 +02:00
2023-11-05 14:47:28 +01:00
```
Usage: ncc [OPTIONS] COMMAND [ARGS]...
Update the nginx cluster configuration
MUST BE RAN ON MASTER (will detect automatically)
Options:
2024-11-04 22:38:57 +01:00
--help Show this message and exit.
2023-11-05 14:47:28 +01:00
Commands:
2024-11-04 22:38:57 +01:00
edit Edit a site
list List all sites and the files they are located in
new Create a new site
test Run nginx -t on the configuration
up Deploy the configuration to the cluster
2023-11-05 14:47:28 +01:00
```
2023-10-25 19:37:39 +02:00
# Contributions
2023-11-05 14:47:28 +01:00
2023-10-25 19:44:27 +02:00
Please use `black` formatter.
2023-11-05 14:47:28 +01:00
You can automate the process by running `cp .githooks/pre-commit .git/hooks/pre-commit && chmod +x .git/hooks/pre-commit` after pulling the repository.