lundi 29 mars 2021

How to serve 2 different flask domain on single VPS server?

I am trying to serve 2 website(domain1.com and domain2.com) running on flask with 2 different domain on 1 VPS server. I have configure the domain.conf files but now with I run the domain1.com I am getting the website but when I run domain2.com I am getting apache default website. Below is my snippet of conf file . appreciate if can help. Thanks.

Domain1 conf file.

<VirtualHost www.domain1.com:80>

         ServerName domain1.com
         ServerAlias www.domain1.com

         Redirect permanent / https://domain1.com/

        # DocumentRoot /var/www/html/domain1/app.wsgi
        WSGIScriptAlias /app1  /var/www/html/domain1/app.wsgi
        <Directory /var/www/html/domain1>
        Order allow,deny
        Allow from all
        </Directory>

       
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
         WSGIScriptAlias / /var/www/html/domain1/app.wsgi
        <Directory /var/www/html/domain1>
        Order allow,deny
        Allow from all
        </Directory>

         ErrorLog ${APACHE_LOG_DIR}/error.log
         CustomLog ${APACHE_LOG_DIR}/access.log combined
    </VirtualHost>
</IfModule> 

Domain 2

<VirtualHost www.domain2.com:80>

#        ServerAdmin webmaster@localhost
         ServerName domain2.com
         ServerAlias www.domain2.com

#         Redirect permanent / https://domain2.com/

#        DocumentRoot /var/www/html/domain2/app.wsgi
        WSGIScriptAlias /app2  /var/www/html/domain2/app.wsgi
        <Directory /var/www/html/domain2>
        Order allow,deny
        Allow from all
        </Directory>

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost> 

APP wsgi setup for both files are the same, just change the last name(domain1 to domain2)

import sys
sys.path.insert(0, "/var/www/html/domain1")
from init import app as application 



Aucun commentaire:

Enregistrer un commentaire