user2761030
user2761030

Reputation: 1485

Issue when setting-up wsgi as an alias path in apache

NOTE: This question is different from 'Add a prefix to all Flask routes' as I am trying to resolve this at apache level. Additional, the suggested fix for flask routes did not work!

Following on from this post, I'm trying to set up apache to serve PHP files by default, but point a given alias (i.e. /flaskapp) to a wsgi path. The wsgi file in turn routes requests to a python flask app.

Here's the apache config that I'm trying (under 000-default.conf):

<VirtualHost *:80>
        ServerName localhost
        ServerAdmin webmaster@localhost

        Alias / /var/www/html/
        <Directory "/var/www/html">
            Order Deny,Allow
            Allow from all
            Require all granted
        </Directory>

        WSGIScriptAlias /flaskapp "/var/www/flaskapp/deploy.wsgi"
        <Directory /var/www/flaskapp>
                 Options +ExecCGI
                 Order allow,deny
                 Allow from all
        </Directory>
</VirtualHost>

After doing a service apache2 restart I find that requests to http://myip/flaskapp result in a 404 error. Everything else works fine.

Things I've tried so far:

Where could I be going wrong?

Upvotes: 1

Views: 1515

Answers (1)

Graham Dumpleton
Graham Dumpleton

Reputation: 58563

Instead of:

    Alias / /var/www/html/
    <Directory "/var/www/html">
        Order Deny,Allow
        Allow from all
        Require all granted
    </Directory>

use:

    DocumentRoot /var/www/html/
    <Directory "/var/www/html">
        Order Deny,Allow
        Allow from all
        Require all granted
    </Directory>

Using '/' with Alias takes precedence over everything else including mod_wsgi's ability to intercept requests at a sub URL. So for stuff at root of the site you need to use DocumentRoot directive.

Upvotes: 1

Related Questions