Skip to content

Commit 9abf051

Browse files
authored
Merge pull request #243 from puzzle/239-task-update-nginx-config-to-include-security-headers
Update Dockerfile and add nginx configuration
2 parents 10edc7a + 564d52c commit 9abf051

File tree

2 files changed

+71
-8
lines changed

2 files changed

+71
-8
lines changed

Dockerfile

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,18 @@ COPY --from=builder /src/public /
1919

2020
RUN wkhtmltopdf --outline-depth 4 --enable-internal-links --enable-local-file-access ./pdf/index.html /pdf.pdf
2121

22-
FROM nginxinc/nginx-unprivileged:1.27-alpine
23-
24-
LABEL maintainer puzzle.ch
25-
LABEL org.opencontainers.image.title "puzzle.ch's Application Migration and Modernization Techlab"
26-
LABEL org.opencontainers.image.description "Container with puzzle.ch's Application Migration and Modernization Techlab content"
27-
LABEL org.opencontainers.image.authors puzzle.ch
28-
LABEL org.opencontainers.image.source https://github.com/puzzle/amm-techlab/
29-
LABEL org.opencontainers.image.licenses CC-BY-SA-4.0
22+
FROM docker.io/nginxinc/nginx-unprivileged:1.28-alpine
23+
24+
LABEL maintainer="Puzzle ITC <https://www.puzzle.ch/>"
25+
LABEL org.opencontainers.image.authors="Puzzle ITC <https://www.puzzle.ch/>"
26+
LABEL org.opencontainers.image.title="puzzle.ch's Application Migration and Modernization Techlab"
27+
LABEL org.opencontainers.image.description="Container with puzzle.ch's Application Migration and Modernization Techlab content"
28+
LABEL org.opencontainers.image.source="https://github.com/puzzle/amm-techlab/"
29+
LABEL org.opencontainers.image.licenses="CC-BY-SA-4.0"
30+
31+
USER root
32+
COPY nginx.conf /etc/nginx/nginx.conf
33+
USER 101
3034

3135
EXPOSE 8080
3236

nginx.conf

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
worker_processes auto;
2+
3+
error_log /var/log/nginx/error.log notice;
4+
pid /tmp/nginx.pid;
5+
6+
events {
7+
worker_connections 1024;
8+
}
9+
10+
http {
11+
port_in_redirect off;
12+
proxy_temp_path /tmp/proxy_temp;
13+
client_body_temp_path /tmp/client_temp;
14+
fastcgi_temp_path /tmp/fastcgi_temp;
15+
uwsgi_temp_path /tmp/uwsgi_temp;
16+
scgi_temp_path /tmp/scgi_temp;
17+
18+
include /etc/nginx/mime.types;
19+
default_type application/octet-stream;
20+
21+
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
22+
'$status $body_bytes_sent "$http_referer" '
23+
'"$http_user_agent" "$http_x_forwarded_for"';
24+
25+
access_log /var/log/nginx/access.log main;
26+
sendfile on;
27+
keepalive_timeout 65;
28+
29+
server {
30+
add_header X-Frame-Options "SAMEORIGIN";
31+
add_header X-Content-Type-Options "nosniff";
32+
add_header X-XSS-Protection "1; mode=block";
33+
add_header Referrer-Policy "strict-origin-when-cross-origin";
34+
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
35+
add_header Cross-Origin-Embedder-Policy "require-corp";
36+
add_header Cross-Origin-Resource-Policy "same-origin";
37+
add_header Cross-Origin-Opener-Policy "same-origin";
38+
add_header X-Permitted-Cross-Domain-Policies "none";
39+
add_header Permissions-Policy "accelerometer=(), ambient-light-sensor=(), autoplay=(), battery=(), camera=(), cross-origin-isolated=(), display-capture=(), document-domain=(), encrypted-media=(), execution-while-not-rendered=(), execution-while-out-of-viewport=(), fullscreen=(self), geolocation=(), gyroscope=(), keyboard-map=(), magnetometer=(), microphone=(), midi=(), navigation-override=(), payment=(), picture-in-picture=(), publickey-credentials-get=(), screen-wake-lock=(), sync-xhr=(self), usb=(), web-share=(), xr-spatial-tracking=()";
40+
add_header Content-Security-Policy "default-src 'self'; script-src 'self' unpkg.com cdn.jsdelivr.net code.jquery.com; style-src 'self' 'unsafe-inline' fonts.googleapis.com cdn.jsdelivr.net; font-src 'self' fonts.gstatic.com cdn.jsdelivr.net";
41+
42+
proxy_hide_header X-Powered-By;
43+
44+
listen 8080;
45+
server_name localhost;
46+
server_tokens off;
47+
48+
location / {
49+
root /usr/share/nginx/html;
50+
index index.html index.htm;
51+
}
52+
53+
error_page 500 502 503 504 /50x.html;
54+
location = /50x.html {
55+
root /usr/share/nginx/html;
56+
}
57+
}
58+
59+
}

0 commit comments

Comments
 (0)