Roundup Tracker

Configuring tracker web interface with Apache and mod_wsgi

The Roundup documentation provides an example on how to configure the tracker web interface with WSGI handler. Another useful configuration option is to use Apache and mod_wsgi extension.

Create a wsgi config file

If your tracker home directory is /trackers/my_tracker then create a file in /trackers directory called my_tracker.wsgi with the following content:

from roundup.cgi.wsgi_handler import RequestDispatcher

tracker_home = '/trackers/my_tracker'
application = RequestDispatcher(tracker_home)

Create a group

Create a group as described in the Unix environment steps - https://www.roundup-tracker.org/docs/installation.html#unix-environment-steps . In this example we created a group called "support" which is then used in the Apache config file.

Configure Apache

When configuring Apache, it is necessary to give the wsgi file correct directory permissions. How this is done differs between different Apache versions. Please consult the mod_wsgi documentation - https://modwsgi.readthedocs.io/en/develop/user-guides/quick-configuration-guide.html and see this code below.

<Directory /usr/local/www/wsgi-scripts>
<IfVersion < 2.4>
    Order allow,deny
    Allow from all
</IfVersion>
<IfVersion >= 2.4>
    Require all granted
</IfVersion>
</Directory>

The configuration file below is running on Apache version greater than 2.4.

<VirtualHost *:80>
        ServerName mytracker.org
        Redirect / https://mytracker.org/

</VirtualHost>
<VirtualHost *:443>
        ServerName mytracker.org

        <Directory /trackers/my_tracker>
                Require all granted
        </Directory>

        WSGIScriptAlias / /trackers/my_tracker.wsgi
        WSGIDaemonProcess my_tracker.roundupuser user=roundupuser group=support threads=25
        WSGIProcessGroup my_tracker.roundupuser

# If interested in enabling Shibboleth authentication, un-comment the lines below.
        #<Location />
        #        AuthType shibboleth
        #        ShibRequestSetting requireSession 1
        #        Require valid-user
        #        RequestHeader set REMOTE-USER %{REMOTE_USER}s
        #</Location>

        SSLEngine on
        SSLCACertificateFile /path/to/file
        SSLCertificateFile /path/to/file
        SSLCertificateKeyFile /path/to/file

</VirtualHost>

Configuring wsgi.py for Python 3.5+, Virtual Env and Xapian

This section describes how to get the WSGI file to recognized roundup xapian. The location of this file is specified in the apache config with the WSGIScriptAlias command.

For this example, the tracker name is called 'it', with trackers stored in the directory /opt/roundup/trackers. If you have several trackers this organization may be useful to you where each tracker is in its own subdirectory. Putting the wsgi.py file in an apache/ subdirectory (e.g. /opt/roundup/trackers/it/apache) means that the WSGIScriptAlias will need to be changed.

Getting roundup to use a virtual env and xapian is a bit tricky. The following code has line numbers so they can be referenced in the text that follows the example.

 1  import sys
 2  # Fix sys.path to contain the VENV path.
 3  # The apt package python3-xapian put the xapian python package in python3.
 4  # Put this path last so it only see the xapian package in python3.
 5  for new_path in ['/usr/local/share/virtualenvs/tracker-env/lib/python3.5/site-packages',
 6                   '/usr/lib/python3/dist-packages']:
 7      if new_path not in sys.path:
 8          sys.path.append(new_path)
 9  
10  from roundup.cgi.wsgi_handler import RequestDispatcher
11  tracker_home = '/opt/roundup/trackers/it'
12  app = RequestDispatcher(tracker_home)
13  
14  def application(environ, start_response):
15      """
16      The main WSGI application.
17      """
18      return app(environ, start_response)

The main idea is to change the Python sys.path so roundup code and xapian code can be found. Line 1 imports the sys package so the sys.path list can be changed. Line 5 contains the virtual env path. The virtualenv in this example is stored in /usr/local/share/virtualenvs/tracker-env.. The full path identifies where roundup is stored in the virtual-env. If a python3 other than python 3.5 is being used, specify that in this path. Line 6 is needed for xapian, When xapian was installed it was placed in the system's python3 path. Line 12 initializes app with the RequestDispatcher. This is done to allow debug code to be added to the application function starting on line 14. If that is not needed, replace lines 12-18 with the following:

application = RequestDispatcher(tracker_home)