添加 'config/varnish.vcl'

This commit is contained in:
zhongjin 2023-05-11 13:10:49 +08:00
parent 6f7fdd7153
commit 6d04fd847b

49
config/varnish.vcl Normal file
View File

@ -0,0 +1,49 @@
acl purge {
"localhost";
"127.0.0.1";
}
backend sqlapi {
.host = "127.0.0.1";
.port = "8080";
}
backend windshaft {
.host = "127.0.0.1";
.port = "8181";
}
sub vcl_recv {
# Allowing PURGE from localhost
if (req.request == "PURGE") {
if (!client.ip ~ purge) {
error 405 "Not allowed.";
}
return (lookup);
}
# Routing request to backend based on X-Carto-Service header from nginx
if (req.http.X-Carto-Service == "sqlapi") {
set req.backend = sqlapi;
remove req.http.X-Carto-Service;
}
if (req.http.X-Carto-Service == "windshaft") {
set req.backend = windshaft;
remove req.http.X-Carto-Service;
}
}
sub vcl_hit {
if (req.request == "PURGE") {
purge;
error 200 "Purged.";
}
}
sub vcl_miss {
if (req.request == "PURGE") {
purge;
error 200 "Purged.";
}
}
Footer