【发布时间】:2014-01-10 22:22:21
【问题描述】:
我在 Apache 中有类似的东西
RewriteCond %{REMOTE_HOST} !^11\.22\.33\.[12]\d\d$ #As example allows from 100 till 200
RewriteCond %{REMOTE_HOST} !^127\.0\.0\.1$
RewriteCond %{TIME} <20140113090000
RewriteRule ^/access-on-monday/ http://www.mysite.com/ [NC,L,R=302]
效果很好。
我需要同样的清漆。 因为 LoadBalancer 后面的服务器它获取带有真实客户端 IP 的 X-Forwarded-For 标头。我仍然在 Apache 中检查 %{REMOTE_HOST} 因为 rpaf_module 已安装。 我在 Varnish 中添加了下一个帮助 ipcastvmod
import ipcast;
acl office {
"localhost";
"11.22.33.100"/24; //Let's think that it matches with 11.22.33.100 - 11.22.33.200
}
sub vcl_recv {
if (req.http.X-Forwarded-For !~ ",") {
set req.http.xff = req.http.X-Forwarded-For;
} else {
set req.http.xff = regsub(req.http.X-Forwarded-For, "^[^,]+.?.?(.*)$", "\1");
}
if (ipcast.clientip(req.http.xff) != 0) {
error 400 "Bad request";
}
if (!client.ip ~ office) {
set req.http.X-Redir-Url = "http://" + req.http.Host + "/";
error 751 "Found";
}
}
然后在 vcl_error 我进行重定向,但在这里没关系。 我的问题是可以像在 Apache 中那样进行基于时间的访问吗?
【问题讨论】:
标签: varnish