A
A
Alex Plotnikov2018-06-29 10:23:28
Nginx
Alex Plotnikov, 2018-06-29 10:23:28

How to properly organize location with internal for mp4 output?

Greetings!
I just can't figure out how to organize the following:
Video is stored on the server in the following ways:
/4/4/3/videoname.mp4
/4/44/3342/videoname.mp4
/24/234/3123/videoname.mp4
etc. .
The server only has nginx.
On the other / other servers, the video generates links of the following type storage.com/24/234/3123/videoname.mp4?hash=45a944d
...

location / {
     proxy_pass http://127.0.0.1:port; //тут висит сервис на go который по hash должен проверять доступ и редиректить на  mp4 с заголовком X-Accel-Redirect
}

location ~ \.mp4$ {
   internal;
}

but with this config, the second location always works when accessing storage.com/24/234/3123/videoname.mp4?hash=45a944d...
how to make the correct nginx config so that the request goes through the hash check service?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
aI3x, 2018-06-29
@TrueDevs

https://habr.com/post/348206/
In your case it's possible like this:

location ~* ".*" {
     proxy_pass http://127.0.0.1:port; //тут висит сервис на go который по hash должен проверять доступ и редиректить на  mp4 с заголовком X-Accel-Redirect
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question