-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: add nginx security headers (#1029)
* refactor: add nginx security headers * chore: update conf * refactor: configurable security headers * refactor: security script changes * refactor: use API_HOST
- Loading branch information
1 parent
c7a2477
commit 7a42f28
Showing
3 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/sh | ||
|
||
API_HOST=$(echo $REACT_APP_API_SERVER_ENDPOINT | sed -e 's|http://||g' -e 's|https://||g') | ||
|
||
tempFile=$(mktemp /etc/nginx/tempfile.XXXXXXXX) | ||
|
||
cat > "${tempFile}" <<EOF | ||
add_header X-Frame-Options "SAMEORIGIN"; | ||
add_header X-Content-Type-Options "nosniff"; | ||
add_header Referrer-Policy "strict-origin-when-cross-origin"; | ||
add_header Content-Security-Policy "default-src 'self'; style-src 'self' 'unsafe-inline'; connect-src 'self' http://${API_HOST} https://${API_HOST} ws://${API_HOST} wss://${API_HOST} blob:;"; | ||
EOF | ||
|
||
if [ "${ENABLE_SECURITY_HEADERS}" = "true" ]; then | ||
sed -i "/#SecurityHeaders/r ${tempFile}" /etc/nginx/nginx.conf.tmpl | ||
fi | ||
|
||
rm "${tempFile}" | ||
|
||
cat /etc/nginx/nginx.conf.tmpl |