I'm rewriting a Flask application to use NGINX Unit and I am now trying to configure static resources. However I'm using flask blueprints and the folder structure is different from what NGINX Unit expects:
{
"match": {
"uri": "/static/my-module/*"
},
"action": {
"share": "/app/myapp/modules/my-module/static/"
}
},
Now what I would like is that everything after /static/my-module/
becomes added to the local path /app/myapp/modules/my-module/static/
like this:
/static/my-module/main.css => /app/myapp/modules/my-module/static/main.css
But what happens is:
/static/my-module/main.css => /app/myapp/modules/my-module/static/static/my-module/main.css
I don't see any way to use regex, or to set make $uri
only be the matching part and not the full.
Given the size of the application it's not trivial to change local path. Now I could do exotic things like symlinking but that's a hassle to maintain.
I'm using unit:1.26.1-python3.9
This is not possible today. In the future you will be able to specify URI rewrites to reconstruct the URI to match the new layout.
For now you can mitigate the symlinking pain by using the $uri
variable explicitly.
"share": "/app/myapp/modules/my-module$uri"
And
$ cd /app/myapp/modules/my-module/static
$ ln -s my-module .