What should I use to replace Apache VirtualHost?

I used VirtualHost for mirroring Django sites in WebFaction - Sharing database and Django projects but each domain load different wsgi.py per domain (wsgi.py has path to each site's settings.py)

Below is VirtualHost settings from httpd.conf.

<VirtualHost *:14529>
    ServerName d1.domainone.com
    ServerAlias d1.domainone.com
    WSGIDaemonProcess dlivbre processes=3 maximum-requests=200 graceful-timeout=10 inactivity-timeout=60 display-name=%{GROUP} python-path=PATHTOPYTHON
    WSGIProcessGroup domain1group
    WSGIScriptAlias / /home/username/apps/testapp/myproject/myproject/wsgi_domain1.py
</VirtualHost>

<VirtualHost *:14529>
    ServerName d2.domaintwo.com
    ServerAlias d2.domaintwo.com
    WSGIDaemonProcess dlivfnp processes=3 maximum-requests=200 graceful-timeout=10 inactivity-timeout=60 display-name=%{GROUP} python-path= PATHTOPYTHON
    WSGIProcessGroup domain2group
    WSGIScriptAlias / /home/username/apps/testapp/myproject/myproject/wsgi_domain2.py
</VirtualHost>

@yoonserk that's a great question!

On our setup the Django backend is running a bare uWSGI server over HTTP, instead of a full Apache+mod_wsgi stack. uWSGI on its own does not have the same sort of virtual hosting capability as Apache.

Instead, you'll need to run a separate uwsgi app and site to replace each of your virtualhosts, with each one pointing at your main app's environment via the following config changes:

uwsgi.ini for domain1 app:

virtualenv = /home/shelluser/apps/testapp/env/
python-path = /home/shelluser/apps/testapp/myproject
wsgi-file = /home/shelluser/apps/testapp/myproject/myproject/wsgi_domain1.py
touch-reload = /home/shelluser/apps/testapp/myproject/myproject/wsgi_domain1.py

uwsgi.ini for domain2 app:

virtualenv = /home/shelluser/apps/testapp/env/
python-path = /home/shelluser/apps/testapp/myproject
wsgi-file = /home/shelluser/apps/testapp/myproject/myproject/wsgi_domain2.py
touch-reload = /home/shelluser/apps/testapp/myproject/myproject/wsgi_domain2.py

@sean Thank you.

Does that mean I need to create Python/uWSGI app per domain?

  • sean replied to this.

    yoonserk Does that mean I need to create Python/uWSGI app per domain?

    Yes, that's correct.

    5 months later
    Mastodon