【发布时间】:2021-07-27 20:48:12
【问题描述】:
我有一个托管在 Firebase 上的网站,使用静态 html,没有使用服务器端函数来传递结果。
运行curl -X PURGE https://mywebsite.com -v -L时,结果为:
{ "status": "ok", "id": "20755-1619059392-3560756" }
我需要一种方法将此操作限制为特定 IP,这样任何人都无法重置我的缓存,这可能会导致额外费用。
此外,Firebase 似乎使用 Varnish 来管理缓存(这是空的)。
我客户的安全顾问向我们发送了有关如何处理此问题的建议,我不确定这是 .htaccess 语法还是什么:
# Varnish recommends to using PURGE method only by valid user,
# for example by ip limiting and for other return 405 Not allowed:
acl purge {
"localhost";
"192.168.55.0"/24;
}
sub vcl_recv {
# allow PURGE from localhost and 192.168.55...
if (req.method == "PURGE") {
if (!client.ip ~ purge) {
return(synth(405,"Not allowed."));
}
return (purge);
}
}
我不知道如何在 Firebase 托管中应用它,我也没有使用服务器功能,只是带有以下标题的常规 firebase.json:
"headers": [
{
"source": "*.[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f].+(css|js)",
"headers": [
{
"key": "Cache-Control",
"value": "public,max-age=31536000,immutable"
}
]
},
{
"source": "**/*.@(json|eot|otf|ttf|ttc|woff|font.css)",
"headers": [
{
"key": "Access-Control-Allow-Origin",
"value": "*"
}
]
}
]
【问题讨论】:
-
这最好直接针对Firebase Support,因为它需要有关内部系统和架构的信息。
标签: firebase caching varnish firebase-hosting purge