Answer the question
In order to leave comments, you need to log in
Is it possible to match uri to real files in nginx?
The task is this. Physically, the files are stored as a hash of their content, such as
files / a0f9 / e225 / c7852fd556678d85587e39ad18f650ab7d2fcd27e6377ebab2a99a27
You must specify a match, for example, when requesting
users / alex / Bezymyannyy.gif give files / a0f9 / e225 / c7852fd556678d85587e39ad18f650ab7d2fcd27e6377ebab2a99a27
possible with nginx it as something to do , without prescribing each file separately in the config, but storing the correspondence table in the database? Or at worst, do the same with apache?
You can, of course, make symbolic links for each of the files, or, when making requests, pull some kind of PHP that will parse the URI, request its presence in the database, and use it to return the desired file. But in the first case, we will get a bunch of symbolic links, in the second case, performance will drop significantly.
Answer the question
In order to leave comments, you need to log in
If there are few files, then you can store the table.
Or if it is possible to generate its name in the file system by the file name in the URI
- through OpenResty in nginx
Otherwise - the database.
Quite suitable, for example, Tarantool or AeroSpike. It will be very fast.
PHP is an extra link here.
with a handler, performance will not drop much (add caching, etc.) and
X-Accel-Redirect will help you.
https://www.opennet.ru/base/net/nginx_x_accel_redi...
Maybe it's better to create a soft/hard link users/alex/Unnamed.gif, which will point to files/a0f9/e225/c7852fd556678d85587e39ad18f650ab7d2fcd27e6377ebab2a99a27
is easier and clearer to understand, more convenient to manage - you can make/delete/move links directly from the file manager.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question