Setup with Nginx
Introduction
This section covers how to set up nginx for the Tutor-Management-System (or your server in general). As for the installation itself docker is required because this setup steps through setting up a docker container running nginx. Furthermore, the steps assume you use docker compose to set up the nginx container, but you can find the corresponding commands below.
Step-by-Step
Using one docker-compose file
These sections should be considered a part of the installation guide.
It assumes that you use docker compose to manage the setup of all required containers.
However, if you want to use docker
commands instead you can find a list of those below aswell.
If you do not want to put the nginx and the tms in the same docker-compose file you can find an explanation on how to do so below.
-
Download the sample nginx configuration files from the documentation.
-
Unzip the downloaded files into a folder of your choice. The Step-by-Step guide assumes it is called
nginx/
.Those files contain a
nginx.conf
file and asites/
folder with more*.conf
files and folders in it. They contain a tested default configuration that works on most systems out-of-the-box.cautionMake sure you do NOT put the
nginx/
folder inside theconfig/
folder used for the TMS itself. -
Verify that you have the following folder and files present:
- nginx/
|--+ certs/ (empty folder)
|--| sites/
|--| sites-available/
|--|--+ tms.conf
|--+ sites-enabled/ (empty folder)
|--+ common_location.conf
|--+ common.conf
|--+ nginx.conf
|--+ ssl.conf -
Gather your SSL certificates and put them in a folder which can be mounted into the docker container. This Step-by-Step guide assumes they are in the
certs/
folder shown above.tipIf you do not have a certificate you can use one from the CA Let's Encrypt.
-
Open the
tms.conf
file inside thesites/sites-available/
folder and make the following adjustment:-
Replace all
<URL>
occurrences with the url (without protocol!) of your server _For example: Your TMS instance has the URLhttps://my-tms-instance.de
you only putmy-tms-instance.de
there.noteIf the TMS instance should be reachable through several URLs you can put all of them in there seperated with spaces, for example:
server_name www.my-tms-instance.de my-tms-instance.de other-url.com;
-
Replace
<PUBLIC_KEY>
with the absolute path the public key will be in the container. For the example dockercompose service and folders this would bessl_certificate /etc/nginx/certs/fullchain.pem;
-
Replace
<PRIVATE>
with the absolute path the private key will be in the container. For the example docker compose service and folders this would bessl_certificate_key /etc/nginx/certs/privkey.pem;
importantIf you want to use your certificate for other configured sites aswell just move the entries
ssl_certificate
andssl_certificate_key
into thessl.conf
file found in thesites/
folder. Remember toinclude
thessl.conf
file in additional site configurations. -
Verify that the URL in the location
/
afterproxy_pass
matches the name of the TMS container followed by the port the server listens on (by default the name istms-server
and the port is8080
).
-
-
Create a symbolic link inside the
sites-enabled/
folder which points to thetms.conf
file by executing the following command inside thesites-enabled/
folder:ln -s ../sites-available/tms.conf .
-
(optional) You can add more sites to your nginx configuration by:
-
Create a new
conf
-file inside thesites-available/
folder containing the necessary configuration. -
Create a symbolic link inside the
sites-enabled/
folder which points to your createdconf
-fileln -s ../sites-available/<NAME-OF-FILE> .
-
-
Add the nginx service to your docker-compose file used during the installation. You can find the service in this sample docker-compose file.
cautionMake sure that the mounted folders match the ones you want to mount (if your folders have different names than this Step-by-Step guide assumes).
-
Proceed with the rest of the installation guide.
Using two docker-compose files
If you want to use different docker-compose files for nginx and the TMS follow these additional steps to get both containers into the same network:
-
Create a new docker network called "proxy_network" by running:
docker network create proxy_network
tipYou can change the name to be what-ever you like but remember it for later.
-
Change the
proxy_network
property in thenetworks
section of both docker-compose files to be like this:networks:
proxy_network:
external:
name: proxy_networkUse correct name of networkIf you changed the name earlier make sure to change the value of the
name
attribute accordingly.
Commands
-
Create the proxy network
docker network create proxy_network
-
Create the nginx container (without starting it):
docker create --name nginx --restart always -p 80:80 -p 433:433 --net proxy_network -v $PWD/nginx/nginx.conf:/etc/nginx/nginx.conf -v $PWD/nginx/sites:/etc/nginx/sites -v $PWD/nginx/certs:/etc/nginx/certs nginx
cautionPlease note: If you renamed the
nginx/
and/orcerts/
folder make sure to adjust the corresponding volumes (-v
) accordingly. All paths must be absolute paths. -
(after completing the rest of the installation) Start the nginx container:
docker start nginx
warningYou have to start the server of the TMS before starting nginx. Otherwise, nginx will throw an error and stop.