Running multiple Flask apps on different subdomains of an ec2 instance Running multiple Flask apps on different subdomains of an ec2 instance flask flask

Running multiple Flask apps on different subdomains of an ec2 instance


Got this working eventually
Helpful reading: Aagudnn.net blog post and Graham's answer on Google Groups.

It turns out that one of my paths was wrong blush and that I still needed to set up ServerName and ServerAlias parts of the config files. Also, I couldn't use the same name for the two separate DaemonProcesses.

All working perfectly now.

My final configuration files:

<VirtualHost *:80>    ServerName www.domain.co.za    ServerAlias domain.co.za         WSGIDaemonProcess www.domain.co.za     WSGIScriptAlias / /var/www/mysite/index.wsgi     <Directory /var/www/mysite/index>            WSGIProcessGroup index        WSGIApplicationGroup %{GLOBAL}        Order deny,allow        Allow from all     </Directory></VirtualHost>

and

<VirtualHost *:80>ServerName www.hello.domain.co.za    WSGIDaemonProcess www.hello.domain.co.za WSGIScriptAlias / /var/www/flaskhello/flaskhello/index.wsgi <Directory /var/www/flaskhello/flaskhello>        WSGIProcessGroup www.hello.domain.co.za    Order deny,allow    Allow from all </Directory></VirtualHost>


This is absolutely doable. You will of course need to use vhosts, if you plan to use different domains, and you might want to look into virtualenv in order to separate applications python stacks (or even LXC containers to increase security a bit). If you're planning to use different applications, then they'll have separate dispatch namespace, so you will have to use redirects without url_for as argument, but actual hardlinked urls. This is very typical setup and it should be very easily doable - get back to us when you meet first concrete issue :)