mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 10:25:52 +02:00
template: added Hotlink Protection #30
This commit is contained in:
parent
f15e66e0de
commit
9ba9711568
1 changed files with 23 additions and 0 deletions
23
template/block/hotlink-protection.conf
Normal file
23
template/block/hotlink-protection.conf
Normal file
|
@ -0,0 +1,23 @@
|
|||
# Nginx UI Template Start
|
||||
name = "Hotlink Protection"
|
||||
author = "@0xJacky"
|
||||
description = { en = "Hotlink Protection Config Template", zh_CN = "防盗链配置模板"}
|
||||
|
||||
[variables.NoneReferer]
|
||||
type = "boolean"
|
||||
name = { en = "Allow Referer is None", zh_CN = "允许空 Referer"}
|
||||
value = false
|
||||
|
||||
[variables.AllowReferers]
|
||||
type = "string"
|
||||
name = { en = "Allow Referers", zh_CN = "允许的 Referers"}
|
||||
value = ""
|
||||
# Nginx UI Template End
|
||||
|
||||
|
||||
location ~ .*\.(jpg|png|js|css)$ {
|
||||
valid_referers {{- if .NoneReferer}} none {{- end}} blocked server_names {{if .AllowReferers}}{{.AllowReferers}}{{- end}};
|
||||
if ($invalid_referer) {
|
||||
return 403;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue