So I want to invoke different instances of Python code based on user's URL (or at least user's domain) from WSGI file. We're running on Apache 2.x + Python + Django stack.
Looks like there should be something like 'SERVER_NAME' or 'HTTP_HOST' key in the os.environ dictionary accessible in WSGI script (here and here). However this key is missing and here's how os.environ.__dict__ looks like when everything is working properly:
{'data': {'LANG': 'C', 'APACHE_LOCK_DIR': 'xxx', 'TZ': 'US/Pacific', 'DJANGO_SETTINGS_MODULE': 'xxx', 'APACHE_RUN_USER': 'xxx', 'PWD': 'xxx', 'APACHE_PID_FILE': 'xxx', 'CELERY_LOADER': 'django', 'APACHE_RUN_DIR': 'xxx', 'APACHE_LOG_DIR': 'xxx', 'APACHE_RUN_GROUP': 'xxx', 'HOME': 'xxx', 'PATH': 'xxx'}}
Domain/URL is a very basic info and I'm surprised I'm failing to find it.
UPDATE: I've settled on a different approach (using Apache Config instead WSGI script). That seems to solve the issue of missing WSGI environment variable. Thanks for all your responses!
os.environ.environin WSGI script though, Apache throws an error: "NameError: name 'environ' is not defined"