For example, the requested url is
photos/100000_0_9-.jpg
I want to calculate the number 100000 and divide it
location ~ /photos/([0-9]+)_0_([0-9]+)-.jpg$ { root '/home/images'; set $id /10000; set $version ; rewrite /photos/([0-9]+)_0_([0-9]+)-.jpg$ /$id/$version/_0_-.jpg; }
Then rewrite to the directory corresponding to the id, but if you do this, the value of id will become 100000/10000 instead of 10.
How to implement this division operation in nginx?
The Nginx configuration file does not seem to support data science operations. You can use the HttpLuaModule written by agentzh.
You can also write a simple mathematical operation extension in bytes https://github.com/arut/nginx-let-mod....