We're Hiring C Developers to Work on Open Source

NGINX Unit
v. 1.27.0

Mailman Web§

To install and run the web UI for the Mailman 3 suite using Unit:

  1. Install Unit with a Python 3.7+ language module.

  2. Follow Mailman’s guide to install its prerequisites and core files, but stop at setting up a WSGI server; we’ll use Unit instead. Also, note the following settings (values from the guide are given after the colon):

    • Virtual environment path: /opt/mailman/venv/
    • Installation path: /etc/mailman3/
    • Static file path: /opt/mailman/web/static/
    • User and group: mailman:mailman

    These are needed to configure Unit.

  3. Run the following command so Unit can access Mailman’s static files:

    # chown -R unit:unit /opt/mailman/web/static/
    

    Note

    The unit:unit user-group pair is available only with official packages, Docker images, and some third-party repos. Otherwise, account names may differ; run the ps aux | grep unitd command to be sure.

    Alternatively, add Unit’s unprivileged user account to Mailman’s group so Unit can access the static files:

    # usermod -a -G mailman unit
    
  4. Next, prepare the Mailman configuration for Unit (use values from Step 2 for share, path, and home):

    {
        "listeners": {
            "*:80": {
                "pass": "routes"
            }
        },
    
        "routes": [
            {
                "match": {
                    "uri": "/static/*"
                },
    
                "action": {
                    "share": "/opt/mailman/web/$uri"
                }
            },
            {
                "action": {
                    "pass": "applications/mailman_web"
                }
            }
        ],
    
        "applications": {
            "mailman_web": {
                "type": "python 3.X",
                "path": "/etc/mailman3/",
                "home": "/opt/mailman/venv/",
                "module": "mailman_web.wsgi",
                "user": "mailman",
                "environment": {
                    "DJANGO_SETTINGS_MODULE": "settings"
                }
            }
        }
    }
    
  5. Upload the updated configuration. Assuming the JSON above was added to config.json:

    # curl -X PUT --data-binary @config.json --unix-socket \
           /path/to/control.unit.sock http://localhost/config/
    

    Note

    The control socket path may vary; run unitd -h or see Startup and Shutdown for details.

    After a successful update, Mailman’s web UI should be available on the listener’s IP address and port:

    Mailman on Unit - Lists Screen