【发布时间】:2021-07-02 14:12:24
【问题描述】:
我的设置如下: Nginx(443 https) -> Varnish(端口 6081) -> Nginx(端口 83 - 应用程序本身)
#nginx https 配置:
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 1800;
proxy_request_buffering off;
proxy_buffering off;
proxy_pass http://127.0.0.1:6081;
}
#part of default.vlc conf:
backend default {
.host = "127.0.0.1";
.port = "83";
}
当然,83 端口还有另一个 nginx 配置,即应用程序本身。 我是这样配置的,所以我可以在 HTTPS 后面运行 varnish。
尝试设置清除以使特定端点的缓存无效,我在 default.vcl 中配置了以下内容:
acl purge {
"127.0.0.1";
"some_public_ip"
}
sub vcl_recv {
if (req.method == "PURGE") {
if (!client.ip ~ purge) {
return (synth(405, "This IP is not allowed to send PURGE requests."));
}
return (purge);
}
}
一切正常,我可以执行了:
curl -X PURGE -I "https://web_server/index.php".
问题是,如果我从 acl 列表中删除“127.0.0.1”,只让“some_public_ip”,它将不再起作用。它将返回“不允许此 IP 发送 PURGE 请求”。 我只希望清除仅适用于“some_public_ip”。 有可能吗?
【问题讨论】:
标签: varnish