I am using nginx for static audio files for my music player mobile app. No dynamic links, no scripts, just static urls. How to close access to files, if query comes not from my app? I don't have any authentication and i don't want to force users use it. I read about http://nginx.org/en/docs/http/ngx_http_auth_request_module.html. Also it would be great to use Laravel for this purpose.
Normally, resource requests from your web page will contain an HTTP referer request header equal to that page's URL. Otherwise, the referer is blank for direct access or will be the URL of another site. Try:
location /static {
if ($http_referer !~ ^http[s]?://example.com) {
return 404;
}
}