unset X-Varnish header to the backend server but keep it in the response to client

EC DIGIT FPFIS digit.fpfis at gmail.com
Fri Nov 8 08:37:50 UTC 2019

 Dear all,

Currently, I migrate a configuration from Varnish 3 to Varnish 6 but I have
an issue concerning unset a header to a backend but keep it in the resp.

Indeed, I cannot use it in vcl_backend_response because it's unset before

In the documentation (
https://book.varnish-software.com/4.0/chapters/VCL_Subroutines.html), I can
see that "if you do not wish to send the X-Varnish header to the backend
server, you can remove it in vcl_miss or vcl_pass. For that case, you can
use unset bereq.http.x-varnish;." but I cannot use bereq in

Do you have any idea how to keep this header in vcl_backend_response but
without send it to backend?

In Varnish 3, I used it in vcl_miss/vcl_pass and the unset bereq was set in

*Vcl code:*

vcl 4.1;
import std;

backend dev {
  .host = "";
  .port = "8080";

sub vcl_recv {
  set req.http.App="App1";
  set req.backend_hint = dev;
  return (hash);

sub vcl_miss {
  unset req.http.App;

sub vcl_pass {
  unset req.http.App;

sub vcl_backend_fetch {
  unset bereq.http.App;

sub vcl_backend_response {
  if (bereq.http.App) {
    set beresp.http.Debug = "test";
    set beresp.ttl = 10s;
    set beresp.grace = 10s;
    return (deliver); // not applied

sub vcl_deliver {
  set res.http.App;


   - Currently: App header in unset for backend & client (unable to use it
   in vcl_backend_response)
   - Goal: App header can be used for conditions in vcl_backend_response
   but not sent to the backend

Best regards,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20191108/8a29c222/attachment.html>

More information about the varnish-misc mailing list