【发布时间】:2020-07-05 03:24:20
【问题描述】:
我正在尝试将 Varnish 配置为不对特定 IP 使用缓存。
我在 Centos 上配置了 Varnish 4,使用 Pound 来管理 HTTPS 请求。 p>
我尝试过这种方法:
Varnish - Bypass Cache for IP Address
基于
https://zcentric.com/2012/03/16/varnish-acl-with-x-forwarded-for-header/
使用一些 C 代码来管理 IP。建议的代码适用于 Varnish3(例如“sp”不再存在,现在有一个 ctx 变量)
我尝试使用这种方法Inline C Varnish (VCL_deliver),但我得到一个 *"initialization from incompatible pointer type [-Werror] in struct sockaddr_storage client_ip_ss = VRT_r_client_ip(ctx); " 错误可能是因为类型也发生了变化。
我尝试使用的代码是:
struct sockaddr_storage *client_ip_ss = VRT_r_client_ip(ctx);
struct sockaddr_in *client_ip_si = (struct sockaddr_in *) client_ip_ss;
struct in_addr *client_ip_ia = &(client_ip_si->sin_addr);
const struct gethdr_s hdr = { HDR_REQ, "20X-Forwarded-For:" };
char *xff_ip = VRT_GetHdr(ctx, &hdr);
但我做错了什么。
我现在有点迷茫,如何在 Varnish 4 上禁用特定 IP 的 varnish?
谢谢
【问题讨论】:
标签: c centos varnish varnish-4 pound