Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

THR-41: adjust csp rule #2736

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ RUN echo "{\"sha\": \"$(git rev-parse HEAD)\", \"version\": \"$(git describe --t
FROM docker.io/nginx:1.25
RUN mkdir /etc/nginx/templates
COPY dockerconf/nginx.conf.template /etc/nginx/templates/default.conf.template
COPY --from=build-stage /app/dist /usr/share/nginx/html
COPY --from=build-stage /app/dist /usr/share/nginx/html/frontend
# second index.html needed for the location /h5p/ in csp rules
COPY --from=build-stage /app/dist /usr/share/nginx/html/h5p

SteKrause marked this conversation as resolved.
Show resolved Hide resolved
EXPOSE 4000
CMD ["nginx", "-g", "daemon off;"]
18 changes: 17 additions & 1 deletion dockerconf/nginx.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ server {

set $csp "default-src 'self'; base-uri 'self'; script-src 'nonce-$request_id' 'strict-dynamic' 'unsafe-inline' https:; object-src 'none'; font-src 'self' data:; img-src 'self' data:; style-src 'self' 'unsafe-inline'; frame-src 'self' ${H5P_FRAME_SRC_URLS}";

set $h5pcsp "default-src 'self'; base-uri 'self'; script-src 'nonce-$request_id' ${H5P_SCRIPT_SRC_URLS} 'unsafe-inline' https:; object-src 'none'; font-src 'self' data:; img-src 'self' ${H5P_IMG_SRC_URLS} data:; style-src 'self' 'unsafe-inline'; frame-src 'self' ${H5P_FRAME_SRC_URLS}";

location /status {
stub_status;
}
Expand Down Expand Up @@ -61,8 +63,22 @@ server {
proxy_pass ${LEGACY_CLIENT_URL};
}

location /h5p/ {
root /usr/share/nginx/html/h5p;
SteKrause marked this conversation as resolved.
Show resolved Hide resolved
index index.html index.htm;
add_header Content-Security-Policy "${h5pcsp}";
add_header X-Content-Type-Options nosniff;
add_header Referrer-Policy 'same-origin';
add_header X-XSS-Protection '1; mode=block';
add_header X-Frame-Options 'SAMEORIGIN';
add_header Permissions-Policy 'fullscreen=(*), sync-xhr=(*), geolocation=(self), midi=(self), microphone=(self), camera=(self), magnetometer=(self), gyroscope=(self), payment=()';
sub_filter_once off;
sub_filter '**CSP_NONCE**' $request_id;
try_files $uri /index.html =404;
}

location / {
root /usr/share/nginx/html;
root /usr/share/nginx/html/frontend;
SteKrause marked this conversation as resolved.
Show resolved Hide resolved
index index.html index.htm;
add_header Content-Security-Policy "${csp}";
add_header X-Content-Type-Options nosniff;
Expand Down
Loading