Skip to content

Commit 0b59885

Browse files
authored
Merge pull request #76 from YuStudy-Inc/nginx-server
added ability to use a secured ssl connection
2 parents 0e27c81 + 2eae097 commit 0b59885

File tree

4 files changed

+48
-8
lines changed

4 files changed

+48
-8
lines changed

Frontend/.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

Frontend/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ node_modules
1111
dist
1212
dist-ssr
1313
*.local
14+
security/*
1415

1516
# Editor directories and files
1617
.vscode/*

Frontend/Dockerfile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
FROM node:18-bullseye
1+
FROM node:18-bullseye AS builder
22

33
WORKDIR /app
4-
54
COPY package.json .
65

76
RUN npm install
8-
9-
RUN npm i -g serve
10-
117
COPY . .
12-
138
RUN npm run build
149

15-
EXPOSE 80
10+
FROM nginx:alpine
11+
12+
COPY --from=builder /app/dist /usr/share/nginx/html
13+
COPY default.conf /etc/nginx/conf.d/
14+
COPY /security/quizslayer.com_ssl_certificate.cer /etc/nginx/certs/
15+
COPY /security/_.quizslayer.com_private_key.key /etc/nginx/certs
1616

17-
CMD [ "serve", "-s", "dist", "-l", "80"]
17+
CMD ["nginx", "-g", "daemon off;"]

Frontend/default.conf

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
server {
2+
listen 80;
3+
listen [::]:80;
4+
server_name quizslayer.com
5+
6+
return 301 https://www.$host$request_uri;
7+
}
8+
9+
server {
10+
listen 80;
11+
listen [::]:80;
12+
13+
server_name localhost;
14+
root /usr/share/nginx/html;
15+
16+
location / {
17+
try_files $uri /index.html;
18+
}
19+
}
20+
21+
server {
22+
listen 443;
23+
server_name quizslayer.com;
24+
ssl_certificate /etc/nginx/certs/quizslayer.com_ssl_certificate.cer;
25+
ssl_certificate_key /etc/nginx/certs/_.quizslayer.com_private_key.key;
26+
27+
return 301 https://www.$host$request_uri;
28+
}
29+
30+
server {
31+
listen 443 ssl;
32+
server_name localhost;
33+
34+
root /usr/share/nginx/html;
35+
location / {
36+
try_files $uri /index.html;
37+
}
38+
}

0 commit comments

Comments
 (0)