本指南介绍了安全 Web 代理的 UrlList 语法。
借助 UrlList,您可以创建许多匹配条目,并在多个规则中重复使用这些条目。
UrlList 语法支持完全匹配域名或按后缀匹配域名,以及包含完整路径且不含参数或包含前缀路径的网址。
支持的通配符
UrlList 支持 * 星号通配符,您可以将其用作前缀来匹配部分子网域或部分路径。
如果您提供部分网域,UrlList 只会与完整的子网域令牌匹配。如果未提供路径分隔符,则 UrlList 与任何路径都匹配。例如,如果您提供 example.com,则 UrlList 会与 example.com/* 匹配,包括该网域中的所有路径。
UrlList 如何解读条目
安全网站代理使用您提供的 UrlList 模式与网址进行匹配,然后确定网址是允许还是禁止访问。
UrlList 会根据以下规则解读条目:
包含英文句号 (
.) 和正斜杠 (/) 的条目必须是格式正确的网址。您可以添加子网域和路径通配符。第一个/字符左侧的令牌会被解读为顶级网域,例如google.com/news中的.com。包含英文句点 (
.) 且不包含正斜杠 (/) 的条目会被解读为域名。您可以添加子网域通配符。在本例中,最右侧的令牌会被解释为顶级域名,例如abc.xyz中的.xyz。所有其他条目均无效。
当 UrlList 模式与包含正斜线 (/) 的值(例如 request.url() 中的值)匹配时,系统会按前面所述的方式解读模式。不过,当 UrlList 模式与不含 / 的值(例如 host() 中的值)进行匹配时,系统只会匹配模式的网域部分。
模式匹配示例
下表显示了示例格式、每种格式匹配的示例网址以及每种格式都不匹配的示例网址。
| 模式 | Matches | 不匹配 |
|---|---|---|
*example.com |
example.com/ server.example.com/ sample.server.example.com/ example.com/path example.com/path?q=query example.com/path/subpath sample.server.example.com/path/ |
myexample.com/ example.com.bad.com/ us13.altostrat.com/go/example.com/path www.google.com/search?q=example.com |
*.example.com |
server.example.com/ sample.server.example.com/ sample.server.example.com/path/ |
myexample.com/ example.com.bad.com/ us13.altostrat.com/go/example.com/path www.google.com/search?q=example.com example.com/ example.com/path example.com/path/subpath |
example.com |
example.com/ example.com/path example.com/path/subpath |
myexample.com/ example.com.bad.com/ us13.altostrat.com/go/example.com/path www.google.com/search?q=example.com server.example.com/ sample.server.example.com/ sample.server.example.com/path/ |
*server.example.com |
server.example.com/ sample.server.example.com/path sample.server.example.com/path/ |
myexample.com/ example.com.bad.com/ us13.altostrat.com/go/example.com/path www.google.com/search?q=example.com example.com/ example.com/path example.com/path/subpath |
*example.com/ |
example.com/ server.example.com/ sample.server.example.com/ |
myexample.com/ example.com.bad.com/ us13.altostrat.com/go/example.com/path www.google.com/search?q=example.com example.com/path/ example.com/path/subpath sample.server.example.com/path/ |
*example.com/path* |
example.com/path example.com/path/subpath sample.server.example.com/path/ |
myexample.com/ example.com.bad.com/ us13.altostrat.com/go/example.com/path www.google.com/search?q=example.com example.com/ server.example.com/ sample.server.com/ |
*example.com/path/* |
example.com/path/subpath sample.server.example.com/path/ |
myexample.com/ example.com.bad.com/ us13.altostrat.com/go/example.com/path www.google.com/search?q=example.com example.com/ server.example.com/ sample.server.example.com/ example.com/path |
*example.com/path/ |
sample.server.example.com/path/ | myexample.com/ example.com.bad.com/ us13.altostrat.com/go/example.com/path www.google.com/search?q=example.com example.com/ sample.example.com/ sample.server.example.com/ example.com/path example.com/path/subpath |
example.com/ |
example.com/ | myexample.com/ example.com.bad.com/ us13.altostrat.com/go/example.com/path www.google.com/search?q=example.com server.example.com/ sample.server.example.com/ example.com/path example.com/path/subpath sample.server.example.com/path/ |