mod-wsgi-van 🚐
Dynamically route mod_wsgi to mod_vhost_alias.
Features
- Isolate virtual environments between vhosts
- Automatically reload deployed vhosts
- Automatically unload deleted vhosts
- Symlinked vhost support
Overview
The router checks the HTTP_HOST on request to decide which vhosts it should be routed to. WSGI apps are lazy loaded. WSGI directories are monitored for mtime changes by default. Symlinks are resolved on access to support deploys that symlink vhosts.
Concerns
- Modules belonging to different vhosts are loaded into the same mod_wsgi process by default.
- Modules loaded outside of an app are shared between all apps in a process.
Install
sudo -H python -m pip install mod-wsgi-van
Example
# /etc/apache2/sites-available/vhosts.conf
<VirtualHost *:80>
UseCanonicalName Off
ServerAlias *.domain.org
VirtualDocumentRoot "/var/www/%0/static"
WSGIDaemonProcess example
WSGIProcessGroup example
WSGIScriptAlias /example /var/wsgi/example.py
</VirtualHost>
# /var/wsgi/example.py
from mod_wsgi_van import Router
application = Router().application
mkdir -p /var/www/example.domain.org/static
mkdir -p /var/www/example.domain.org/wsgi
python -m venv /var/www/example.domain.org/.venv
/var/www/example.domain.org/.venv/bin/python -m pip install Flask
# /var/www/example.domain.org/wsgi/app.py
from flask import Flask
app = Flask(__name__)
...
API
Router- Attributes
base_path: str = "/var/www"- The location of the vhosts.venv_name: str = ".venv"- The name of the virtual environment directory inside the vhost.wsgi_dir: str = "wsgi"- The name of the WSGI directory inside the vhost.module_name: str = "app"- The name of the module inside of the WSGI directory.object_name: str = "app"- The name of the object inside of the module.update_interval: float = 1.0- The interval for polling symlinks in seconds.
- Methods
get_server_path(host_name: str) -> pathlib.Path- Override to change the vhost naming scheme.get_venv_paths(path: pathlib.Path) -> list[pathlib.Path]- Override to change the venv site packages locations.get_version(path: pathlib.Path) -> Any- Override to customize the change detection strategy.
- Attributes
Metadata
Release files for mod-wsgi-van 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mod_wsgi_van-1.0.0.tar.gz | 6.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mod_wsgi_van-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.5 kB
Release files / mod_wsgi_van-1.0.0.tar.gz
| Download URL | mod_wsgi_van-1.0.0.tar.gz |
|---|---|
| Size | 6.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b4c3ffcec0d31ba32996a23fb42389fa42b1e2beb040c531cb59d35a106f0224
|
|
BLAKE2b-256 checksum How to use checksums |
635c25495eb19f3b96a4ae234a582df4dbe5aabd22ddd8f3e45a86235d675546
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Release files / mod_wsgi_van-1.0.0-py3-none-any.whl
| Download URL | mod_wsgi_van-1.0.0-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
23dbae7a9558531540e7746f3da38839d08e62fe321e985df333792a503c6008
|
|
BLAKE2b-256 checksum How to use checksums |
244f55a4aaad6f07925c9388da99a659e1961aa6a6babe2369d681475484954d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|