Skip to content

Commit e9db70d

Browse files
committed
Configure secure headers and static buildpacks
1 parent 54079c4 commit e9db70d

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

Dockerfile

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM node:14.1-alpine AS builder
2+
3+
WORKDIR /opt/web
4+
COPY package.json package-lock.json ./
5+
RUN npm install
6+
7+
ENV PATH="./node_modules/.bin:$PATH"
8+
9+
COPY . ./
10+
RUN npm run build
11+
12+
FROM nginx:1.17-alpine
13+
RUN apk --no-cache add curl
14+
RUN curl -L https://github.com/a8m/envsubst/releases/download/v1.1.0/envsubst-`uname -s`-`uname -m` -o envsubst && \
15+
chmod +x envsubst && \
16+
mv envsubst /usr/local/bin
17+
COPY ./nginx.config /etc/nginx/nginx.template
18+
CMD ["/bin/sh", "-c", "envsubst < /etc/nginx/nginx.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'"]
19+
COPY --from=builder /opt/web/build /usr/share/nginx/html

nginx.config

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
server {
2+
listen ${PORT:-80};
3+
server_name _;
4+
5+
root /usr/share/nginx/html;
6+
index index.html;
7+
8+
location / {
9+
try_files $$uri /index.html;
10+
}
11+
12+
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self' data:; connect-src 'self' https://*.okta.com;";
13+
add_header Referrer-Policy "no-referrer, strict-origin-when-cross-origin";
14+
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains";
15+
add_header X-Content-Type-Options nosniff;
16+
add_header X-Frame-Options DENY;
17+
add_header X-XSS-Protection "1; mode=block";
18+
add_header Feature-Policy "accelerometer 'none'; camera 'none'; microphone 'none'";
19+
add_header Permissions-Policy "accelerometer=(), ambient-light-sensor=(), autoplay=(), camera=(), encrypted-media=(), fullscreen=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), midi=(), payment=(), picture-in-picture=(), sync-xhr=(self 'https://haveibeenpwned.com' 'https://twofactorauth.org'), usb=(), vr=()";
20+
}

static.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"headers": {
3+
"/**": {
4+
"Content-Security-Policy": "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self' data:; connect-src 'self' https://*.okta.com;",
5+
"Referrer-Policy": "no-referrer, strict-origin-when-cross-origin",
6+
"Strict-Transport-Security": "max-age=63072000; includeSubDomains",
7+
"X-Content-Type-Options": "nosniff",
8+
"X-Frame-Options": "DENY",
9+
"X-XSS-Protection": "1; mode=block",
10+
"Feature-Policy": "accelerometer 'none'; camera 'none'; microphone 'none'"
11+
}
12+
},
13+
"https_only": true,
14+
"root": "build/",
15+
"routes": {
16+
"/**": "index.html"
17+
}
18+
}

0 commit comments

Comments
 (0)