2.6. The WSGI Script

Apache2 and Nginx are using a WSGI script to start the application.

This script is usually located at /etc/edumfa/edumfaapp.py or /etc/edumfa/edumfaapp.wsgi and has the following contents:

import sys
sys.stdout = sys.stderr
from edumfa.app import create_app
# Now we can select the config file:
application = create_app(config_name="production", config_file="/etc/edumfa/edumfa.cfg")

In the create_app-call you can also select another config file.

2.6.1. WSGI configuration for the Apache webserver

The site-configuration for the Apache webserver to use WSGI should contain at least:

<VirtualHost _default_:443>
    WSGIScriptAlias /      /etc/edumfa/edumfaapp.wsgi
    WSGIDaemonProcess edumfa processes=1 threads=15 display-name=%{GROUP} user=edumfa
    WSGIProcessGroup edumfa
    WSGIApplicationGroup %{GLOBAL}
    WSGIPassAuthorization On

2.6.2. Running several instances with the Apache webserver

You can run several instances of eduMFA on one Apache2 server by defining several WSGIScriptAlias definitions pointing to different wsgi-scripts, which again reference different config files with different database definitions.

To run further Apache instances add additional lines in your Apache config:

WSGIScriptAlias /instance1 /etc/edumfa1/edumfaapp.wsgi
WSGIScriptAlias /instance2 /etc/edumfa2/edumfaapp.wsgi
WSGIScriptAlias /instance3 /etc/edumfa3/edumfaapp.wsgi
WSGIScriptAlias /instance4 /etc/edumfa4/edumfaapp.wsgi

It is a good idea to create a subdirectory in /etc for each instance. Each wsgi script needs to point to the corresponding config file edumfa.cfg.

Each config file can define its own

  • database

  • encryption key

  • signing key

  • logging configuration

To create the new database you need The edumfa-manage Script. The edumfa-manage command reads the configuration from /etc/edumfa/edumfa.cfg by default.

If you want to use another instance with another config file, you need to set an environment variable and create the database like this:

EDUMFA_CONFIGFILE=/etc/edumfa3/edumfa.cfg edumfa-manage create_tables

This way you can use edumfa-manage for each instance.