Builds for
1 pipeline
failed
in
1 minute 23 seconds
Merge branch 'feature/https' into develop
Showing
6 changed files
with
35 additions
and
3 deletions
... | @@ -8,6 +8,8 @@ services: | ... | @@ -8,6 +8,8 @@ services: |
8 | restart: unless-stopped | 8 | restart: unless-stopped |
9 | ports: | 9 | ports: |
10 | - "3000:3000" | 10 | - "3000:3000" |
11 | + volumes: | ||
12 | + - /etc/letsencrypt:/etc/letsencrypt | ||
11 | 13 | ||
12 | web: | 14 | web: |
13 | build: | 15 | build: |
... | @@ -15,4 +17,7 @@ services: | ... | @@ -15,4 +17,7 @@ services: |
15 | dockerfile: ./web/Dockerfile | 17 | dockerfile: ./web/Dockerfile |
16 | restart: unless-stopped | 18 | restart: unless-stopped |
17 | ports: | 19 | ports: |
20 | + - "443:443" | ||
18 | - "80:80" | 21 | - "80:80" |
22 | + volumes: | ||
23 | + - /etc/letsencrypt:/etc/letsencrypt | ... | ... |
1 | import express from "express"; | 1 | import express from "express"; |
2 | import socketIo, { Server as IoServer } from "socket.io"; | 2 | import socketIo, { Server as IoServer } from "socket.io"; |
3 | -import { createServer } from "http"; | 3 | +import { createServer } from "https"; |
4 | import { RoomManager } from "./room/RoomManager"; | 4 | import { RoomManager } from "./room/RoomManager"; |
5 | import { Connection } from "./connection/Connection"; | 5 | import { Connection } from "./connection/Connection"; |
6 | import { SocketIoWrapper } from "./connection/SocketWrapper"; | 6 | import { SocketIoWrapper } from "./connection/SocketWrapper"; |
7 | +import { readFileSync } from "fs"; | ||
7 | 8 | ||
8 | export class Server { | 9 | export class Server { |
9 | public readonly port: number; | 10 | public readonly port: number; |
... | @@ -13,7 +14,20 @@ export class Server { | ... | @@ -13,7 +14,20 @@ export class Server { |
13 | this.port = port; | 14 | this.port = port; |
14 | 15 | ||
15 | const app = express(); | 16 | const app = express(); |
16 | - const server = createServer(app); | 17 | + const server = createServer( |
18 | + { | ||
19 | + cert: readFileSync( | ||
20 | + "/etc/letsencrypt/live/2020105578.oss2021.tk/cert.pem" | ||
21 | + ), | ||
22 | + key: readFileSync( | ||
23 | + "/etc/letsencrypt/live/2020105578.oss2021.tk/privkey.pem" | ||
24 | + ), | ||
25 | + ca: readFileSync( | ||
26 | + "/etc/letsencrypt/live/2020105578.oss2021.tk/fullchain.pem" | ||
27 | + ), | ||
28 | + }, | ||
29 | + app | ||
30 | + ); | ||
17 | this.io = new socketIo.Server(server, { | 31 | this.io = new socketIo.Server(server, { |
18 | cors: { | 32 | cors: { |
19 | origin: "*", | 33 | origin: "*", | ... | ... |
... | @@ -19,6 +19,7 @@ FROM nginx:latest | ... | @@ -19,6 +19,7 @@ FROM nginx:latest |
19 | COPY web/default.conf /etc/nginx/conf.d/default.conf | 19 | COPY web/default.conf /etc/nginx/conf.d/default.conf |
20 | COPY --from=build /usr/web/build /usr/web/build | 20 | COPY --from=build /usr/web/build /usr/web/build |
21 | 21 | ||
22 | +EXPOSE 443 | ||
22 | EXPOSE 80 | 23 | EXPOSE 80 |
23 | 24 | ||
24 | CMD ["nginx", "-g", "daemon off;"] | 25 | CMD ["nginx", "-g", "daemon off;"] | ... | ... |
1 | server { | 1 | server { |
2 | listen 80; | 2 | listen 80; |
3 | + return 301 https://$host$request_uri; | ||
4 | +} | ||
5 | + | ||
6 | +server { | ||
7 | + listen 443 ssl default_server; | ||
8 | + server_name 2020105578.oss2021.tk; | ||
9 | + | ||
10 | + ssl_certificate /etc/letsencrypt/live/2020105578.oss2021.tk/fullchain.pem; | ||
11 | + ssl_certificate_key /etc/letsencrypt/live/2020105578.oss2021.tk/privkey.pem; | ||
12 | + | ||
3 | location / { | 13 | location / { |
4 | root /usr/web/build; | 14 | root /usr/web/build; |
5 | index index.html; | 15 | index index.html; | ... | ... |
1 | import React from "react"; | 1 | import React from "react"; |
2 | import { io } from "socket.io-client"; | 2 | import { io } from "socket.io-client"; |
3 | 3 | ||
4 | -export const socket = io(`http://${window.location.hostname}:3000/`); | 4 | +export const socket = io(`https://${window.location.hostname}:3000/`); |
5 | const SocketContext = React.createContext(socket); | 5 | const SocketContext = React.createContext(socket); |
6 | 6 | ||
7 | export const SocketProvider = SocketContext.Provider; | 7 | export const SocketProvider = SocketContext.Provider; | ... | ... |
-
Please register or login to post a comment