Nginx automated configurator
Overview
This repo is used for automated nginx deploy on your server using gitlab-ci/cd.
Nginx is a beautiful tool that helps with load balansing and proxing sites to manage your site architecture.
In current repo nginx was dockerized to provide full in-docker-infrastructure. Of course you can add custom configuration that point onto real IP-address, or wathsoever.
Main advantage in using this project is helpful Makefile that makes your life much easier.
You can find help about make targets by running make help
. This help generated automatically by parsing makefile comments.
All available targets listed in help.
Installation
At first we need to add nginx user, that will be like an nginx manager and grant access rights to gitlab-runner to write in some specific directories. Also create ssl directory somwhere on server and add read permissions to gitlab-runner to it.
useradd -m -U nginx
groupadd nginxmanager
usermod -a -G nginxmanager nginx
usermod -a -G nginxmanager gitlab-runner
mkdir ${SSL_DIR}
Then create a folder that gitlab-runner will have access rights to and where prod nginx will be stored.
su nginx
cd
mkdir runner
chgroup nginxmanager runner
chmod g+w runner
exit
# Do not forget to check that gitlab-runner can write in this folder.
After that add in gitlab following build variables:
-
APP_DIR
: where nginx will be located. -
SITES_BACKUP
: temporary folder where gitlab will copy all sites from current gitlab version. -
SSL_DIR
: where ssl certs will be located.
Extending
Also nginx configurator makefile can be extended without pain.
To write a new function you just need to add target in Makefile as usual.
If you do not want function to appear in help mark it as hidden
by adding leading underscore.
new_target: - will be shown in help.
_hidden_target: - will not be shown.
To add description in help: add comment just below target.
# Prints action | parameters description or overview.
documented_target: dependency
@echo "action"