Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ jobs:
files: |
docker-bake.hcl
fpm/**
${ matrix.webserver }/**
${{ matrix.webserver }}/**
dev/**

- name: Build
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
This repository contains a base image with Alpine + PHP + (Caddy or Nginx), which you can use to build your docker image with your code.

[Documentation can be found here](https://developer.shopware.com/docs/guides/hosting/installation-updates/docker.html)

The Nginx, Caddy and FrankenPHP configurations send `script-src 'none'; object-src 'none'; frame-src 'none'; base-uri 'none'; form-action 'none'` for static SVG files and existing HTML files under `public/media` and `public/thumbnail`. Application-rendered HTML and bundled HTML applications retain their own response policies. Custom static documents must work without scripts, embedded documents, base URL overrides or form submissions; images and styles remain permitted. Development images inherit the corresponding server configuration.
6 changes: 6 additions & 0 deletions caddy/rootfs/etc/caddy/Caddyfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ log

route {
root * /var/www/html/public
@staticDocuments {
file
path_regexp staticDocuments (?i)([.]svg$|^/(media|thumbnail)/.*[.]html$)
}
header @staticDocuments Content-Security-Policy "script-src 'none'; object-src 'none'; frame-src 'none'; base-uri 'none'; form-action 'none'"

encode gzip zstd

@theme path /theme/*
Expand Down
6 changes: 6 additions & 0 deletions frankenphp/rootfs/etc/caddy/Caddyfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@

:8000 {
root * /var/www/html/public
@staticDocuments {
file
path_regexp staticDocuments (?i)([.]svg$|^/(media|thumbnail)/.*[.]html$)
}
header @staticDocuments Content-Security-Policy "script-src 'none'; object-src 'none'; frame-src 'none'; base-uri 'none'; form-action 'none'"

encode zstd gzip

log
Expand Down
19 changes: 15 additions & 4 deletions nginx/rootfs/etc/nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ http {
deny all;
}

# Stored HTML must not affect pages rendered by PHP.
location ~* ^/(media|thumbnail)/.*[.]html$ {
try_files $uri =404;
expires 1y;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
add_header Content-Security-Policy "script-src 'none'; object-src 'none'; frame-src 'none'; base-uri 'none'; form-action 'none'";
}

# Allow sitemap requests to hit the shopware application
location ~ ^/sitemap/.*\.(xml|xml\.gz)$ {
try_files $uri /index.php$is_args$args;
Expand All @@ -64,7 +72,7 @@ http {
open_file_cache_errors off;

location ~* ^.+\.svg {
add_header Content-Security-Policy "script-src 'none'";
add_header Content-Security-Policy "script-src 'none'; object-src 'none'; frame-src 'none'; base-uri 'none'; form-action 'none'";
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
log_not_found off;
}
Expand All @@ -82,13 +90,13 @@ http {
try_files $uri =410;

location ~* ^.+\.svg {
add_header Content-Security-Policy "script-src 'none'";
add_header Content-Security-Policy "script-src 'none'; object-src 'none'; frame-src 'none'; base-uri 'none'; form-action 'none'";
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
log_not_found off;
}
}

location ~* ^.+\.(?:css|cur|js|jpe?g|gif|ico|png|svg|webp|html|woff|woff2|xml)$ {
location ~* ^.+\.(?:css|cur|js|jpe?g|gif|ico|png|webp|html|woff|woff2|xml)$ {
expires 1y;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";

Expand All @@ -109,7 +117,10 @@ http {
}

location ~* ^.+\.svg$ {
add_header Content-Security-Policy "script-src 'none'";
try_files $uri /index.php$is_args$args;
expires 1y;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
add_header Content-Security-Policy "script-src 'none'; object-src 'none'; frame-src 'none'; base-uri 'none'; form-action 'none'";
}

location ^~ /protected_files/ {
Expand Down
Loading