Skip to content

Commit 6f54104

Browse files
committed
Remove xkey header in vcl_deliver when not in debug mode
Avoid leaking internal id info from applications in tags by unsetting the header in prod.
1 parent fa2239e commit 6f54104

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

doc/varnish-configuration.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,10 @@ and include ``resources/config/varnish/fos_tags_xkey.vcl`` in your VCL:
214214
call fos_tags_xkey_recv;
215215
}
216216
217+
sub vcl_deliver {
218+
call fos_tags_xkey_deliver;
219+
}
220+
217221
Note that there is no xkey VCL file for Varnish version 3 because the
218222
varnish-modules are only available for Varnish 4.1 or newer.
219223

resources/config/varnish/fos_tags_xkey.vcl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,10 @@ sub fos_tags_xkey_recv {
3434
return (synth(200, "Purged "+req.http.n-gone+" objects, expired "+req.http.n-softgone+" objects"));
3535
}
3636
}
37+
38+
sub fos_tags_xkey_deliver {
39+
if (!resp.http.X-Cache-Debug) {
40+
// Remove tag headers when delivering to non debug client
41+
unset resp.http.xkey;
42+
}
43+
}

tests/Functional/Fixtures/varnish/fos_xkey.vcl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ sub vcl_backend_response {
2929
sub vcl_deliver {
3030
call fos_debug_deliver;
3131
call fos_ban_deliver;
32+
call fos_tags_xkey_deliver;
3233
}

0 commit comments

Comments
 (0)