petr
petr

Reputation: 1119

mod_wsgi: How to run different apps under single domain?

I have a domain example.com and I run a standard Apache there (serving static files and PHP). I want to run Python served pages on subdomain.example.com.

I managed to configure Apache to do this and there is a Flask app running at subdomain.example.com. However, in the virtual host config file, the whole subdomain is tight to this one single app. I would like to go further and run several different apps on this subdomain.

For example:

subdomain.example.com/app1/ would run /var/www/apps/app1/app.wsgi subdomain.example.com/app2/ would run /var/www/apps/app2/app.wsgi

and so on...

Furthermore I would like this to be fully automatic, that is when I set up new folder in /var/www/apps/, I could reach the app through the Apache without further configuration.

I can see several ways of doing this:

  1. Configure Apache to route every subdomain.example.com request to a single "meta app" in Python which would run a specific app based on given URL.
  2. Do some magic with Apache configuration that would take care of this automatically.
  3. Maybe use nginx? I don't really have much experience with this, but someone told me this could solve the problem.

Is there any best practice about how to do this? Thank you.

Upvotes: 2

Views: 269

Answers (1)

djc
djc

Reputation: 11731

It looks like you should be able to do this by providing a directory path (in your case, /var/www/apps) to the WSGIScriptAlias directive. Read more here:

https://modwsgi.readthedocs.org/en/develop/configuration-directives/WSGIScriptAlias.html

This seems like a neater solution than using a meta app.

Upvotes: 2

Related Questions