Adjusted with our own flavour, but mostly by re-using existing and excellent code and step-by-step guide
The name lb-rp is a condenced form of load blancer - reverse proxy and is part of the infrastructure hosting web application developed and mentained by SKDE. lb-rp is based on NGINX Open Source and applied as a docker container alongside our config and other cogs that make up mongr.no:
Our application of NGINX as proxy and load balancer is descibed below. Description of the other parts can be found elsewhere, for instance our shinyproxy and the qmongr shiny application.
Configuration of NGINX is defined in the data/nginx/mongr.conf-file. Please refere to the NGINX documentation and relevant settings of the hosting environment. All changes must be committed to this repository using git.
All steps are performed from the command line at the server instance that will be running the nginx service. Make sure that the content of this repo is available at the server by using git:
git clone https://github.com/mong/lb-rp.git
the first time. For consecutive updates navigate into the lb-rp directory and issue:
git pull origin master
If the server to be hosting nginx is just created (vanilla state) make sure docker-ce and docker-compose are installed along with other relevant settings by running the following script:
sudo ./install.sh
Then, make sure that the values set at the top 15-ish lines of init-letsencrypt.sh are sensible and run the script:
./init-letsencrypt.sh
This ensures that users can connect securely to our site by the kind help of Let's Encrypt.
As a result of running the above script the nginx docker container is now running but should at this stage be taken down by:
docker kill $(docker ps -q)
Both the nginx and its accompanying certbot container are configured to regularly refresh config and certificates. Any changes or updates should therefore a matter of just updating from the github repository. Move into the lb-rp directory and issue:
git pull origin master
and the rest should take care of itself. If waiting it out is not an option the services can also be manually restarted as described below.
To enable lb-rp use docker-compose to start the relevant services in detached mode:
docker-compose up -d
To stop the same services do:
docker-compose down
To bring the services down an up again in one go do:
docker-compose restart
For other options please consult the docker compose docs.
