template: added Hotlink Protection #30

This commit is contained in:
0xJacky 2023-04-10 23:56:56 +08:00
parent f15e66e0de
commit 9ba9711568
No known key found for this signature in database
GPG key ID: B6E4A6E4A561BAF0

View 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;
}
}