Answer the question
In order to leave comments, you need to log in
How to set up hotlinking in Nginx?
There is a file server on nginx, access to it via http, i.e. site.ru/file.exe and the file is downloaded.
To prevent third-party resources from copying these links to themselves and not loading the server, protection against hotlicking was configured by:
location ~* ^.+\.(iso|img|pkg|exe|zip|rar)$ {
valid_referers none blocked mysite.ru www.mysite.ru;
if ($invalid_referer) {
return https://mysite.ru/;
}
}
Answer the question
In order to leave comments, you need to log in
In general, the problem was solved quite simply, removed "none" from this line - valid_referers none blocked mysite.ru www.mysite.ru;
And direct links stopped working, including if the link is specified on a third-party site through target="_blank"
And exactly the goal in "and did not load the server"? Because nginx makes the distribution of statics very efficient and the server does not load it.
And if the real goal is to protect the file from downloading, then it is done differently within the framework of nginx.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question