取消清漆中的授权标头,但也将标头发送到后端

时间:2019-02-06 13:41:18

标签: authorization varnish varnish-vcl

我想删除清漆vcl中的Authorization标头,但也需要将此标头发送到后端。

sub vcl_recv {
    unset req.http.Authorization;
}

1 个答案:

答案 0 :(得分:0)

这似乎是个坏主意,但是使用一些基本的VCL绝对可以实现。例如:

sub vcl_recv {
    if (req.http.Authorization) {
        set req.http.Authorization-Copy = req.http.Authorization;
        unset req.http.Authorization;
    } else {
        unset set req.http.Authorization-Copy;
    }
}

sub vcl_backend_fetch {
    if (bereq.http.Authorization-Copy) {
        set bereq.http.Authorization = bereq.http.Authorization-Copy;
        unset bereq.http.Authorization-Copy;
    }
}