Answer the question
In order to leave comments, you need to log in
How to use Nginx X-Accel-Redirect to proxy remote files in a Ruby on Rails application?
I want to use a proxy server to be able to collect file stats and not provide direct urls to users.
And in the future, be able to switch to another service without changing the original URL.
Right now I'm using Cloudinary and the file path looks like this:
<%= cl_video_tag("dog") %>
=> https://res.cloudinary.com/demo/video/upload/dog.mp4
Answer the question
In order to leave comments, you need to log in
Consider an example, without reference to the programming language:
There is a URL https://res.cloudinary.com/demo/video/upload/dog.mp4
There is a file /var/www/files/dog.mp4
There is nginx that processes client requests
There is some backend code
In nginx
1. Create an internal location in nginx, for example:
location /video/ {
internal;
root /var/www/files/;
}
X-Accel-Redirect https://res.cloudinary.com/video/dog.mp4
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question