Skip to content

Commit d5fd2ca

Browse files
committed
update nginx conf and use official nginx container
1 parent 5934c2e commit d5fd2ca

File tree

3 files changed

+48
-26
lines changed

3 files changed

+48
-26
lines changed

.github/workflows/test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
node-version: 24
2323
- name: Setup Node Modules and Angular
2424
run: |
25-
npm ci && \
25+
npm i && \
2626
npm install -g @angular/cli@21
2727
- name: Lint Application
2828
run: ng lint

Dockerfile

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
FROM node:20 AS build
1+
FROM node:24 AS build
22
WORKDIR /app
33
COPY ./ .
4-
RUN npm ci && \
5-
npm install -g @angular/cli@17 && \
4+
RUN npm i && \
5+
npm install -g @angular/cli@21 && \
66
ng build
77

8-
FROM bitnami/nginx:latest AS final
9-
USER root
10-
RUN apt-get update && apt-get upgrade -y
11-
USER 1001
12-
COPY nginx.conf /opt/bitnami/nginx/conf/server_blocks/nginx.conf
13-
COPY --from=build /app/dist/website/browser* /app
8+
FROM nginx:1.29.4-alpine AS final
9+
COPY nginx.conf /etc/nginx/conf.d/default.conf
10+
COPY --from=build /app/dist/website/browser* /usr/share/nginx/html

nginx.conf

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,58 @@
1+
map $request_id $csp_nonce {
2+
default $request_id;
3+
}
4+
15
server {
2-
listen 80;
3-
root /app;
6+
listen 80 default_server;
7+
server_name _;
8+
9+
root /usr/share/nginx/html;
410
index index.html;
511

6-
# Set security headers to protect against common web vulnerabilities
7-
add_header X-Frame-Options "DENY";
8-
add_header X-Content-Type-Options "nosniff";
9-
add_header X-XSS-Protection "1; mode=block";
10-
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
11-
add_header Content-Security-Policy "default-src 'self' https://*.thefirepanel.com; worker-src 'self' blob:; style-src 'self' 'unsafe-inline' 'nonce-$request_id' https://fonts.googleapis.com; script-src 'unsafe-inline' 'self' 'nonce-$request_id'; font-src 'self' https://fonts.gstatic.com; img-src 'self' https://i.ytimg.com data:; base-uri 'self'; object-src 'none'; connect-src *; frame-src https://www.youtube.com;";
12+
# -------------------------
13+
# Security headers
14+
# -------------------------
15+
add_header X-Frame-Options "DENY" always;
16+
add_header X-Content-Type-Options "nosniff" always;
17+
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
18+
add_header Permissions-Policy "geolocation=(), microphone=(), camera=()" always;
1219

20+
add_header Content-Security-Policy "
21+
default-src 'self' https://*.thefirepanel.com;
22+
base-uri 'self';
23+
object-src 'none';
24+
frame-ancestors 'none';
25+
worker-src 'self' blob:;
26+
style-src 'self' 'unsafe-inline' https://fonts.googleapis.com;
27+
script-src 'self' 'nonce-$csp_nonce';
28+
font-src 'self' https://fonts.gstatic.com;
29+
img-src 'self' https://i.ytimg.com data:;
30+
connect-src *;
31+
frame-src https://www.youtube.com;
32+
" always;
33+
34+
# -------------------------
35+
# Redirects
36+
# -------------------------
1337
location ~ ^/(team|author)/ {
14-
return 301 /about;
38+
return 308 /about;
1539
}
1640

1741
location = /wiki/ndevices/simplexmnc/ {
18-
return 301 /tools;
42+
return 308 /tools;
1943
}
2044

2145
location ~ ^/(wiki|blog|tag)/ {
22-
return 301 https://wiki.thefirepanel.com;
46+
return 308 https://wiki.thefirepanel.com$request_uri;
2347
}
2448

25-
# Define location block for handling requests
49+
# -------------------------
50+
# SPA handling
51+
# -------------------------
2652
location / {
27-
# Try serving the requested URI, fall back to index.html if not found
28-
try_files $uri /index.html;
29-
# Enable nonce on app to protect with CSP
53+
try_files $uri $uri/ /index.html;
54+
3055
sub_filter_once off;
31-
sub_filter random_nonce_value $request_id;
56+
sub_filter random_nonce_value $csp_nonce;
3257
}
3358
}

0 commit comments

Comments
 (0)