M
M
MakarkaZhuk2020-07-08 09:33:21
Nginx
MakarkaZhuk, 2020-07-08 09:33:21

Disable hotlinking for a specific list of sites in nginx?

The standard scheme for banning hotlinking is known - (forbidden for everyone except search engines and social networks). I also need to configure the config to prohibit only a specific list from several domains. Those. everyone, except for a few specified domains, is allowed to hotlink. Please share the code

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
dodo512, 2020-07-08
@MakarkaZhuk

if ($http_referer ~* "^https?://(site1\.ru|site2\.com|site3\.org)") {
    return 403;
}

Or
valid_referers ~^(?!site1\.ru|site2\.com|site3\.org);

if ($invalid_referer) {
    return 403;
}

L
Larisa .•º, 2020-07-08
@barolina

An example of preventing hotlinking with nginx

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question