Reputation: 711
I have a server where I am hosting several apps. They are all accessible on their own subdirectories through the same server name, so my app foo
is found at www.servername.com/foo
and bar
is found at www.servername.com/bar
and so on. Most of these apps are Flask apps with the route and the static files configured through apache VirtualHost *:443
to run SSL.
I have been given another Flask app, baz
, to run on the server which has been configured to spin up into two Docker containers, one for the app and one for the database. I have managed to adjust my apache .conf file as follows:
<VirtualHost *:443>
ServerName www.servername.com
# some additional config for my other apps, in Directories and static aliases
ProxyPreserveHost On
SSLProxyEngine On
<Proxy *>
Allow from *
</Proxy>
ProxyPass "/baz" "http://<IP address>:5000"
ProxyPassReverse "/baz" "http://<IP address>:5000"
</VirtualHost>
I think the configuration is reaching the running container, because when I go to www.servername.com/baz
it redirects to www.servername.com/login
. It should redirect to www.servername.com/baz/login
, but clearly something hasn't gone right. How can I get the proxy to correctly direct all baz
traffic through the /baz
subdirectory?
Additionally, I can manually navigate to www.servername.com/baz/login
to see the login page for the baz
app, but it appears not to have loaded the CSS, so I assume the static files are not being loaded. Do I need to set up an alias for these static files too, like I do with my other non-Docker Flask apps? If so, the standard format that I usually use:
Alias baz/static /path/to/baz/static
is not working. On a whim, I also tried something weirder just to see if it would work:
Alias "baz/static" "http://<IP address>:5000/static"
but this didn't work either. Perhaps it will be fixed by addressing the proxy routing issue above, but how can I make the static files accessible to the baz
app?
Upvotes: 1
Views: 485
Reputation: 1130
It sounds like the website that is running under /baz
doesn't know that's where it's running and so is rendering URLs under /
instead. You have a couple of options:
baz.servername.com
. Then the Flask apps can just use /
freely without conflicts./baz
to prefix every URL it serves.Upvotes: 1