but I think this is trying to find a file at /app/static-live/static/ instead of /app/static-live/
How can I get it to look in the correct directory? Do I use rewrite to rewrite paths /app/static-live/static/ to /app/static-live/
I just realized that I may be better off moving to a directory structure like DJANGO_STATIC_ROOT=/app/live/static
STAGING_DJANGO_STATIC_ROOT=/app/staging/static
I believe that for a path-scoped site prod.example.com/static/ with a root /app/static-live, a request for prod.example.com/static/foo will serve a file off the disk at /app/static-live/foo.
So, the double-up of /static/ won’t happen.
Path-scoped sites automatically strip the base path from the request for the purposes of all matchers (e.g. for rewrites and similar directives where you specify base paths) as well as from the static file server for this very reason (they don’t strip it from placeholders like {uri} and {path} though).
But I know it has caused trouble, too. What do you think we should do regarding this in v2? (Sorry to derail slightly, keep the conversation going as you were!)
I think if you ever have a path-scoped root, the default behaviour should be to strip that base path for the purposes of the path of the file to serve.
Like location /foo with its own root in nginx, or example.com/foo with its own root.
I can’t think of a situation where you’d want to have a subfolder with a separate web root where you didn’t want it stripped - or perhaps more accurately, there’s no situation where having it stripped would be a problem, because you’re already specifying a web root, so you might as well make it intuitive and accurate.
TL;DR: Path matcher + specified web root = strip the matched base path (and probably document this behaviour).