vmod_header can be used in vcl_backend_fetch?

Guillaume Quintard guillaume at varnish-software.com
Mon Nov 27 12:23:42 UTC 2017


So the varnishlog confirms the vmods works as expected:

-   BereqUnset     Accept-Encoding: gzip
-   BereqHeader    Accept-Encoding: aaaa
-   BereqHeader    Accept-Encoding: bbbb

bereq is "BackEnd REQuest", if you want to change the "BackEnd RESPonse",
use beresp.http.*.

And you can simply to:

set bereq.http.accept-encoding = "br, gzip";

Just know that while varnish natively support gzip, it's not the case for
brotli. You can have a look at this blog post:
https://info.varnish-software.com/blog/varnish-cache-brotli-compression

-- 
Guillaume Quintard

On Mon, Nov 27, 2017 at 1:04 PM, matrix <matrix at matrix2000.name> wrote:

> hi thank you for your reply
>
> According to varnishlog Bereq header are displayed but origin server
> log, only Accept-Encoding: aaaa .
>
> -   BereqHeader    Accept-Encoding: aaaa
> -   BereqHeader    Accept-Encoding: bbbb
>
> I would like to change  Accept-Encoding Header to br,gzip, because the
> varnish is force replaced Accept-Encoding gzip when backend request.
>
> VCL
> unset bereq.http.Accept-Encoding;
> header.append(bereq.http.Accept-Encoding, "aaaa");
> header.append(bereq.http.Accept-Encoding, "bbbb");
>
>
> Full varnishlog below
>
> *   << BeReq    >> 3
> -   Begin          bereq 2 fetch
> -   Timestamp      Start: 1511783436.988432 0.000000 0.000000
> -   BereqMethod    GET
> -   BereqURL       /cache/200.php
> -   BereqProtocol  HTTP/1.1
> -   BereqHeader    User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu)
> libcurl/7.19.7 NSS/3.27.1 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> -   BereqHeader    Accept: */*
> -   BereqHeader    host: test.com
> -   BereqHeader    Accept-Encoding: gzip
> -   BereqHeader    Surrogate-Capability: key=ESI/1.0
> -   BereqHeader    X-Cache-Key: /cache/200.php
> -   BereqHeader    X-Varnish: 3
> -   VCL_call       BACKEND_FETCH
> -   BereqUnset     Accept-Encoding: gzip
> -   BereqHeader    Accept-Encoding: aaaa
> -   BereqHeader    Accept-Encoding: bbbb
> -   VCL_return     fetch
> -   BackendOpen    21 boot.backend1 127.0.0.1 81 127.0.0.1 51782
> -   BackendStart   127.0.0.1 81
> -   Timestamp      Bereq: 1511783436.988549 0.000118 0.000118
> -   Timestamp      Beresp: 1511783437.198227 0.209795 0.209677
> -   BerespProtocol HTTP/1.1
> -   BerespStatus   404
> -   BerespReason   Not Found
> -   BerespHeader   Date: Mon, 27 Nov 2017 11:50:37 GMT
> -   BerespHeader   Content-Type: text/html; charset=UTF-8
> -   BerespHeader   Transfer-Encoding: chunked
> -   BerespHeader   Connection: keep-alive
> -   BerespHeader   Vary: Accept-Encoding
> -   TTL            RFC 86400 10 -1 1511783437 1511783437 1511783437 0 0
> -   VCL_call       BACKEND_RESPONSE
> -   TTL            VCL 300 10 0 1511783437
> -   VCL_return     deliver
> -   Storage        file disk
> -   ObjProtocol    HTTP/1.1
> -   ObjStatus      404
> -   ObjReason      Not Found
> -   ObjHeader      Date: Mon, 27 Nov 2017 11:50:37 GMT
> -   ObjHeader      Content-Type: text/html; charset=UTF-8
> -   ObjHeader      Vary: Accept-Encoding
> -   Fetch_Body     2 chunked stream
> -   BackendReuse   21 boot.backend1
> -   Timestamp      BerespBody: 1511783437.198340 0.209908 0.000113
> -   Length         16
> -   BereqAcct      569 0 569 178 16 194
> -   End
>
> *   << Request  >> 2
> -   Begin          req 1 rxreq
> -   Timestamp      Start: 1511783436.988227 0.000000 0.000000
> -   Timestamp      Req: 1511783436.988227 0.000000 0.000000
> -   ReqStart       x.x.x.x 62656
> -   ReqMethod      GET
> -   ReqURL         /cache/200.php?1234
> -   ReqProtocol    HTTP/1.1
> -   ReqHeader      User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu)
> libcurl/7.19.7 NSS/3.27.1 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> -   ReqHeader      Accept: */*
> -   ReqHeader      Host:test.com
> -   ReqHeader      Accept-Encoding: gzip,deflate
> -   VCL_call       RECV
> -   ReqUnset       Host:test.com
> -   ReqHeader      host: test.com
> -   ReqUnset       Accept-Encoding: gzip,deflate
> -   ReqHeader      Accept-Encoding: gzip
> -   ReqHeader      Surrogate-Capability: key=ESI/1.0
> -   ReqURL         /cache/200.php
> -   VCL_return     hash
> -   VCL_call       HASH
> -   ReqHeader      X-Cache-Key: /cache/200.php
> -   VCL_Log        redhash
> -   ReqUnset       X-Cache-Key: /cache/200.php
> -   ReqHeader      X-Cache-Key: /cache/200.php
> -   VCL_return     lookup
> -   VCL_call       MISS
> -   VCL_Log        redmiss
> -   VCL_return     fetch
> -   Link           bereq 3 fetch
> -   Timestamp      Fetch: 1511783437.198397 0.210170 0.210170
> -   RespProtocol   HTTP/1.1
> -   RespStatus     404
> -   RespReason     Not Found
> -   RespHeader     Date: Mon, 27 Nov 2017 11:50:37 GMT
> -   RespHeader     Content-Type: text/html; charset=UTF-8
> -   RespHeader     Vary: Accept-Encoding
> -   RespHeader     X-Varnish: 2
> -   RespHeader     Age: 0
> -   RespHeader     Via: 1.1 varnish-v4
> -   VCL_call       DELIVER
> -   VCL_Log        reddeliver
> -   RespUnset      X-Varnish: 2
> -   RespUnset      Via: 1.1 varnish-v4
> -   VCL_return     deliver
> -   Timestamp      Process: 1511783437.198471 0.210244 0.000074
> -   RespHeader     Content-Length: 16
> -   Debug          "RES_MODE 2"
> -   RespHeader     Connection: keep-alive
> -   Timestamp      Resp: 1511783437.198515 0.210288 0.000044
> -   ReqAcct        219 0 219 282 16 298
> -   End
>
> *   << Session  >> 1
> -   Begin          sess 0 HTTP/1
> -   SessOpen       x.x.x.x 62656 0.0.0.0:80 172.26.12.250 80
> 1511783436.987762 20
> -   Link           req 2 rxreq
> -   SessClose      REM_CLOSE 0.217
> -   End
>
>
> 2017-11-27 20:21 GMT+09:00 Guillaume Quintard <guillaume at varnish-software.
> com>:
> > Hi,
> >
> > I would expect to have two AE headers, one with aaa and one with bbb,
> would
> > you have the varnishlog of that particular bereq?
> >
> > Also, it's probably out of scope, but are you actually changing the
> > Accept-Encoding header, or is that just for the example?
> >
> > --
> > Guillaume Quintard
> >
> > On Mon, Nov 27, 2017 at 12:15 PM, matrix <matrix at matrix2000.name> wrote:
> >>
> >> I would like to control bereq header below.(varnish4.1.8)
> >>
> >> header.append(bereq.http.Accept-Encoding, "aaa");
> >> header.append(bereq.http.Accept-Encoding, "bbb");
> >>
> >> But bereq.http.Accept-Encoding header is "aaa". (not "aaa,bbb")
> >> is it possible to handle the bereq using vmod_header ?
> >>
> >> or is it varnish-modules bug?
> >>
> >> Best regards.
> >> _______________________________________________
> >> varnish-misc mailing list
> >> varnish-misc at varnish-cache.org
> >> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20171127/31ca34e4/attachment-0001.html>


More information about the varnish-misc mailing list