仅将 Varnish 用作没有缓存的反向代理

Using Varnish only as a Reverse Proxy without caching

我想知道我可以在我的 VCL 中放入什么来告诉 Varnish 不要缓存请求并将所有请求传递给后端,因为我想使用 Varnish 作为反向代理来隐藏实际我的后端 IP。 我做了一些研究,但没有发现任何具体的东西。 我正在使用 Varnish 3,我实际的 Varnish VCl 是:

backend default {
.host = "127.0.0.1";
.port = "8080";
}

谢谢。

您需要覆盖默认处理以强制 'pass'

这在 vcl_recv 和 vcl_fetch

中都有

sub vcl_recv { pass; }

sub vcl_fetch { pass; }

如果你想让 Varnish 完全不处理请求,你应该使用管道。这可以防止 varnish 重写 headers。响应直接从清漆发回。

sub vcl_recv {
    return(pipe);
}