Running multiple flask applications with different domain names using mod_wsgi

56 views
Skip to first unread message

Joel Divekar

unread,
Jan 30, 2022, 2:26:19 PM1/30/22
to modwsgi

Trying to run 2 different flask applications with different domain names from same server using mod_wsgi + Apache2.

This is the settings configured in httpd.conf

# For www.yyy.com
WSGIDaemonProcess yyy python-path=/var/www/yyy WSGIScriptAlias / /var/www/yy/wsgi.py process-group=yyy application-group=%{GLOBAL}

WSGIDaemonProcess zzz python-path=/var/www/zzz WSGIScriptAlias / /var/www/zzz/wsgi.py process-group=zzz application-group=%{GLOBAL}

and created virtualhost confs /etc/httpd/conf.d/yyy.conf & zzz.conf similar to

<VirtualHost *:80>
      ServerName www.yyy.com
      ServerAdmin joel
      DocumentRoot /var/www/yyy
      ErrorLog /var/log/httpd/error.log
      CustomLog /var/log/httpd/access.log combined
      Alias /static /var/www/yyy/static
      <Directory /var/www/yyy/static>
            Require all granted
      </Directory>
      <Directory /var/www/yyy>
      <Files wsgi.py>
            Require all granted
      </Files>
      </Directory>
</VirtualHost>

but whatever a request is received by the server, only the landing page of the first application that is configured in httpd.conf is displayed.

Kindly advice what I am missing in the configuration.

Regards

Joel

Graham Dumpleton

unread,
Jan 30, 2022, 4:00:58 PM1/30/22
to mod...@googlegroups.com
The WSGIDaemonProcess/WSGIScriptAlias should be inside of the respect VirtualHost definitions, not in httpd.conf.

In other words:

<VirtualHost *:80>
      ServerName www.yyy.com
      ServerAdmin joel
      DocumentRoot /var/www/yyy
      ErrorLog /var/log/httpd/error.log
      CustomLog /var/log/httpd/access.log combined

      WSGIDaemonProcess yyy python-path=/var/www/yyy
      WSGIScriptAlias / /var/www/yy/wsgi.py process-group=yyy application-group=%{GLOBAL}
      Alias /static /var/www/yyy/static
      <Directory /var/www/yyy/static>
            Require all granted
      </Directory>
      <Directory /var/www/yyy>
      <Files wsgi.py>
            Require all granted
      </Files>
      </Directory>
</VirtualHost>

Similarly for the other host.

Graham

--
You received this message because you are subscribed to the Google Groups "modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to modwsgi+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/modwsgi/de27a457-63f1-410d-adbd-971b2abb45ffn%40googlegroups.com.

Joel Divekar

unread,
Feb 2, 2022, 5:17:42 AM2/2/22
to modwsgi
Thanks it worked.
Reply all
Reply to author
Forward
0 new messages