Black Lives Matter. Please consider donating to Black Girls Code today.
Dash HoloViews is now available! Check out the docs.

Setting up Dash with Apache+mod_wsgi+Flask in subdirectory. Pathnames or 404


I’m stuck. I am trying to setup a dash app using Apache 2.4, Flask, and mod_wsgi. I was able to get it to work fine in the root directory, but could not get it to work in a subdirectory. It works when I set this in apache’s configuration:

WSGIScriptAlias / /var/www/hello/hello.wsgi/

but if instead I do

WSGIScriptAlias /hello /var/www/hello/hello.wsgi/

then I get the “Error loading layout” message. I checked other posts in this forum, and it seemed a problem of setting url_base_pathname, so I changed it to url_base_pathname=’/hello/’ and then I got a 404 error. It beats me.

In other words: Apache is serving the app as expected (at if I do not modify url_base_pathname, but in this case dash looks for _dash-dependencies and _dash-layout in the wrong place (I verified that this is the case in Apache’s logs). If I do modify url_base_pathname, then I get the 404 error. How is this happening? Does someone know?

For reference:
Ubuntu bionic 18.04 LTS

Apache configuration:

WSGIDaemonProcess hello user=ubuntu group=ubuntu python-home=/home/ubuntu/hello/env python-path=/home/ubuntu/hello
WSGIProcessGroup hello
WSGIScriptAlias / /var/www/hello/hello.wsgi/
<Directory /var/www/hello>
  <Files hello.wsgi>
    Require all granted

from flask import Flask
app = Flask(__name__)
import dash
import dash_html_components as html
dash_app = dash.Dash(__name__,
dash_app.layout = html.Div([
    html.H2('Hello World'),


from hello import app as application