I would like to reject the direct link of the image in Nginx.There are many tutorials on how to deny non-domains referrals using valid_refer, but I don't know how to deny direct links in the specified domain.Can invalid_refer do the same thing?
location~.(gif|png|jpe?g)${
invalid_refer none blocked to *badsite.com;
if($invalid_refer){
return403;
}
}
The $invalid_refer
variable appears to be set by the valid_refers
directive, but I am not good at setting negative regular expressions in the valid_refer
directive, so what do you think about implementing it like this?
map$http_refer$block_by_refer{
~^https?://bad.example.com/1;
default0;
}
...
location~\.(gif|png|jpe?g)${
if($block_by_refer){
return403;
}
}
© 2024 OneMinuteCode. All rights reserved.