Domain not serving wsgi file, but the IP does

August 4, 2014 913 views

Hello,

I'm trying to deploy a flask application on my droplet, which is running ubuntu, but every time I change my virtual host file to the domain, it just serves the index of /var/www/html and not the wsgi which I specified in the virtual host file. However, if I use my droplet's IP for "ServerName", it works fine.

Any ideas?

Thanks

2 Answers

Could you post your Apache VirtualHost? Have you set WSGIScriptAlias ? It should look something like:

<VirtualHost *>
    ServerName example.com

    WSGIDaemonProcess yourapplication user=user1 group=group1 threads=5
    WSGIScriptAlias / /var/www/yourapplication/yourapplication.wsgi

    <Directory /var/www/yourapplication>
        WSGIProcessGroup yourapplication
        WSGIApplicationGroup %{GLOBAL}
        Order deny,allow
        Allow from all
    </Directory>
</VirtualHost>

Also make sure that mod_wsgi is installed:

sudo apt-get install libapache2-mod-wsgi
sudo a2enmod wsgi
sudo service apache2 restart

Check out Flask's docs on using it with Apache.

Like I was saying, the virtual host file works with the IP, but not the domain. Here it is though:

<VirtualHost *>
        ServerName 192.241.184.178
        ServerAdmin admin@testing.com
        WSGIScriptAlias / /var/www/html/Training/training.wsgi
        <Directory /var/www/html/Training/Training/>
            Order allow,deny
            Allow from all
        </Directory>
        Alias /static /var/www/html/Training/Training/static
        <Directory /var/www/html/Training/Training/static/>
            Order allow,deny
            Allow from all
        </Directory>
        ErrorLog ${APACHE_LOG_DIR}/error.log
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

When I replace "ServerName" with "training.fstichem.com", it just displays the folders.

Have another answer? Share your knowledge.