오지민

Delete server.js

Showing 1 changed file with 0 additions and 52 deletions
1 -const express = require("express");
2 -const fs = require("fs");
3 -const path = require("path");
4 -const HTTPS = require("https");
5 -
6 -const app = express();
7 -const domain = "2020105619.oss2021.tk";
8 -const sslport = 8080;
9 -
10 -app.use(express.static(path.join(__dirname, "kakao")));
11 -app.use(express.static(path.join(__dirname, "public")));
12 -
13 -app.get("/", function (req, res) {
14 - res.sendFile(path.join(__dirname + "/main.html"));
15 -});
16 -
17 -app.get("/geolocation", function (req, res) {
18 - res.sendFile(path.join(__dirname + "/kakao/kakaomap.html"));
19 -});
20 -
21 -try {
22 - const option = {
23 - ca: fs.readFileSync("/etc/letsencrypt/live/" + domain + "/fullchain.pem"),
24 - key: fs
25 - .readFileSync(
26 - path.resolve(
27 - process.cwd(),
28 - "/etc/letsencrypt/live/" + domain + "/privkey.pem"
29 - ),
30 - "utf8"
31 - )
32 - .toString(),
33 - cert: fs
34 - .readFileSync(
35 - path.resolve(
36 - process.cwd(),
37 - "/etc/letsencrypt/live/" + domain + "/cert.pem"
38 - ),
39 - "utf8"
40 - )
41 - .toString(),
42 - };
43 -
44 - HTTPS.createServer(option, app).listen(sslport, () => {
45 - console.log(`[HTTPS] Server is started on port ${sslport}`);
46 - });
47 -} catch (error) {
48 - console.log(
49 - "[HTTPS] HTTPS 오류가 발생하였습니다. HTTPS 서버는 실행되지 않습니다."
50 - );
51 - console.log(error);
52 -}