<div dir="ltr">
<div>Hello Dridi and thank you for you answer.</div><div><br></div><div>I
 try to use vmod_var but there are another issue. Apparently I need to 
use global var to get it between vcl_recv & vcl_backend_response 
(it's empty if I try a 'simple' var)</div><div><br></div><div>Moreover, the global var are kept for the next requests so I fear that a conflict can appear between requests.<br></div><div><br></div><div>Best regards,</div>

</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le ven. 8 nov. 2019 à 17:26, Dridi Boukelmoune <dridi@varni.sh> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
Thank you for taking the time to reach out to this list.<br>
<br>
On Fri, Nov 8, 2019 at 8:39 AM EC DIGIT FPFIS <<a href="mailto:digit.fpfis@gmail.com" target="_blank">digit.fpfis@gmail.com</a>> wrote:<br>
><br>
> Dear all,<br>
><br>
> 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.<br>
><br>
> Indeed, I cannot use it in vcl_backend_response because it's unset before (vcl_pass/vcl_backend_fetch)...<br>
><br>
> In the documentation (<a href="https://book.varnish-software.com/4.0/chapters/VCL_Subroutines.html" rel="noreferrer" target="_blank">https://book.varnish-software.com/4.0/chapters/VCL_Subroutines.html</a>), 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 vcl_miss/vcl_pass.<br>
<br>
This is a bug in the varnish book, it lives here:<br>
<br>
<a href="https://github.com/varnish/varnish-book" rel="noreferrer" target="_blank">https://github.com/varnish/varnish-book</a><br>
<br>
> Do you have any idea how to keep this header in vcl_backend_response but without send it to backend?<br>
><br>
> In Varnish 3, I used it in vcl_miss/vcl_pass and the unset bereq was set in vcl_fetch.<br>
<br>
Nowadays you would do that in vcl_backend_fetch, but the tricky part<br>
is that you no longer have access to the client context. So instead<br>
you need to "pollute" your bereq to find that information or use a<br>
different tool like vmod_var or something similar.<br>
<br>
> Vcl code:<br>
><br>
> vcl 4.1;<br>
> import std;<br>
><br>
> backend dev {<br>
>   .host = "127.0.0.1";<br>
>   .port = "8080";<br>
> }<br>
><br>
> sub vcl_recv {<br>
>   set req.http.App="App1";<br>
>   set req.backend_hint = dev;<br>
>   return (hash);<br>
> }<br>
><br>
> sub vcl_miss {<br>
>   unset req.http.App;<br>
> }<br>
><br>
> sub vcl_pass {<br>
>   unset req.http.App;<br>
> }<br>
<br>
Don't do anything in vcl_miss or vcl_pass.<br>
<br>
> sub vcl_backend_fetch {<br>
>   unset bereq.http.App;<br>
> }<br>
<br>
Here you may do something like this:<br>
<br>
sub vcl_backend_fetch {<br>
  if (bereq.http.App) {<br>
    var.set("app", bereq.http.App);<br>
    unset bereq.http.App;<br>
  }<br>
}<br>
<br>
> sub vcl_backend_response {<br>
>   if (bereq.http.App) {<br>
>     set beresp.http.Debug = "test";<br>
>     set beresp.ttl = 10s;<br>
>     set beresp.grace = 10s;<br>
>     return (deliver); // not applied<br>
>   }<br>
> }<br>
<br>
And here, something like that:<br>
<br>
sub vcl_backend_response {<br>
  if (var.get("app")) {<br>
    set beresp.ttl = 10s;<br>
    set beresp.grace = 10s;<br>
    return (deliver);<br>
  }<br>
}<br>
<br>
> sub vcl_deliver {<br>
>   set res.http.App;<br>
> }<br>
><br>
> Goal:<br>
><br>
> Currently: App header in unset for backend & client (unable to use it in vcl_backend_response)<br>
> Goal: App header can be used for conditions in vcl_backend_response but not sent to the backend<br>
<br>
See <a href="https://github.com/varnish/varnish-modules/blob/master/docs/vmod_var.rst" rel="noreferrer" target="_blank">https://github.com/varnish/varnish-modules/blob/master/docs/vmod_var.rst</a><br>
<br>
Dridi<br>
</blockquote></div>