Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions 6.7/rootfs/etc/varnish/default.vcl
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ sub vcl_backend_response {
}

sub vcl_deliver {
if (req.url ~ "^/(media|thumbnail)/") {
set resp.http.Content-Security-Policy = "script-src 'none'; object-src 'none'; frame-src 'none'; base-uri 'none'; form-action 'none'";
}

## we don't want the client to cache anything except assets and store-api responses
if (resp.http.Cache-Control !~ "private" && req.url !~ "^/(theme|media|thumbnail|bundles|store-api)/") {
set resp.http.Pragma = "no-cache";
Expand Down
4 changes: 4 additions & 0 deletions 6.8/rootfs/etc/varnish/default.vcl
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ sub vcl_backend_response {
}

sub vcl_deliver {
if (req.url ~ "^/(media|thumbnail)/") {
set resp.http.Content-Security-Policy = "script-src 'none'; object-src 'none'; frame-src 'none'; base-uri 'none'; form-action 'none'";
}

unset resp.http.xkey;
unset resp.http.X-Varnish;
unset resp.http.Via;
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
The image bases on the official [Varnish image](https://hub.docker.com/_/varnish) and contains the Shopware default VCL.
The containing VCL is for the usage with xkeys.

## Static asset Content Security Policy

Responses under `/media/` and `/thumbnail/` receive `Content-Security-Policy: script-src 'none'; object-src 'none'; frame-src 'none'; base-uri 'none'; form-action 'none'`, including cache hits and error responses. This applies to every file type in these directories. HTML documents in these paths cannot execute scripts, submit forms or embed documents. Responses outside these paths retain their existing policy.

<details>
<summary>Config for Shopware 6.7</summary>

Expand Down