강동현

express에 https적용

......@@ -8,6 +8,8 @@ services:
restart: unless-stopped
ports:
- "3000:3000"
volumes:
- /etc/letsencrypt:/etc/letsencrypt
web:
build:
......
import express from "express";
import socketIo, { Server as IoServer } from "socket.io";
import { createServer } from "http";
import { createServer } from "https";
import { RoomManager } from "./room/RoomManager";
import { Connection } from "./connection/Connection";
import { SocketIoWrapper } from "./connection/SocketWrapper";
import { readFileSync } from "fs";
export class Server {
public readonly port: number;
......@@ -13,7 +14,20 @@ export class Server {
this.port = port;
const app = express();
const server = createServer(app);
const server = createServer(
{
cert: readFileSync(
"/etc/letsencrypt/live/2020105578.oss2021.tk/cert.pem"
),
key: readFileSync(
"/etc/letsencrypt/live/2020105578.oss2021.tk/privkey.pem"
),
ca: readFileSync(
"/etc/letsencrypt/live/2020105578.oss2021.tk/fullchain.pem"
),
},
app
);
this.io = new socketIo.Server(server, {
cors: {
origin: "*",
......