How to deploy a Dash app via gunicorn behind a proxy when the app is not mounted at '/'?

I’m trying to add a Dash component to an existing Flask app. The main Flask app is served ba Gunicorn behind a nginx proxy server, but it is not at the root of the server. Basically all requests to http://intranet.server/ go to some static html directory, only requests to http://intranet.server/… go to my Flask app.

I’ve managed to make it work, but on the way I have run into several issues like not being able to load my CSS any more. Here’s what it looks like:

<Location “/dham”>
ProxyPass unix:/var/run/dham_wsgi/socket|http://intranet.server/dham
</Location>

gunicorn service:

ExecStart = gunicorn --env ‘SCRIPT_NAME=/dham’ …

Creation of Dash app:

dash_app = Dash(‘repa’, serve_locally=True,
                requests_pathname_prefix=‘/dham/repa/statistik/’,
                routes_pathname_prefix=‘/repa/statistik/’)

This is imported into to my main app like this:

dash_app.init_app(app)

This kind of works but hast the following issues:

  1. CSS stylesheets located in the assets directory are not loaded
  2. When using Flask’s built in development server, this doesn’t work any more because Flask doesn’t know what /dham means. (The development server of course has my app at ‘/’, not ‘/dham/’

The fact that my app isn’t mounted at root has had me tearing my hair out because it’s not a scenario that is succinctly documented anywhere. But, years ago, I did get it to work for my main Flask app eventually with the configuration above. Now with Dash, I hope these woes don’t start all over again.