Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
鉴于 Varnish 3.0.2 中的这个 VCL 代码:
sub vcl_recv { if (req.http.host !~ "^(?i)(www|m|mobile)\.example\.com$" || req.http.host !~ "^(?i)example\.com$") { error 403 "Forbidden"; } return(lookup); }
谁能解释为什么我在“www.example.com”上得到 403?
谢谢
我不知道 varnish 及其语法,但我将其解释||为合乎逻辑的OR. 所以www.example.com不匹配第二种选择==>它是真的,你输入if.
||
OR
www.example.com
if
可能您想要一个逻辑AND?如果两者都不正确,那么 403?
所以试试:
if (req.http.host !~ "^(?i)(www|m|mobile)\.example\.com$" && req.http.host !~ "^(?i)example\.com$") { error 403 "Forbidden"; }