Answer the question
In order to leave comments, you need to log in
How to redirect request to api if 404 for image?
The usual situation is nested folders (from parts of the name) to store pictures not in a bunch in the image folder , but in a structure like image/ab/cd/efg/abcdefg.png . There may not be a picture (thumbnail) in place, then it needs to be made from the original, and it has a different name.
The logic is simple: the API generates a picture and saves it in folders - after that the picture is available via a direct link. API available on different port and different URI
- Image URI: image/ab/cd/efg/abcdefg.png (port 80)
-
URI of api method: image/abcdefg.png (port 8080)
processing in an API method?
PS: now it turns out to proxy the request unchanged through a named location. But you need to change the URI image/ ab/cd/efg/abcdefg.png -> image/abcdefg.png and throw out the folder structure from it.
Answer the question
In order to leave comments, you need to log in
I think something like this:
location /image/(.*\.png)$ {
error_page 404 = http://127.0.0.1:8080/image/$1;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question