Node.js HTTPS 설정하기
페이지 정보
작성자 미친새 작성일 23-03-20 16:13 조회 7,939 댓글 0본문
const express = require('express');
const http = require('http');
const https = require('https');
const fs = require('fs');
const HTTP_PORT = 8080;
const HTTPS_PORT = 8443;
const options = {
key: fs.readFileSync('./rootca.key'),
cert: fs.readFileSync('./rootca.crt')
};
const app = express();
// Default route for server status
app.get('/', (req, res) => {
res.json({ message: `Server is running on port ${req.secure ? HTTPS_PORT : HTTP_PORT}` });
});
// Create an HTTP server.
http.createServer(app).listen(HTTP_PORT);
// Create an HTTPS server.
https.createServer(options, app).listen(HTTPS_PORT);
https://cinema4dr12.tistory.com/984
const http = require('http');
const https = require('https');
const fs = require('fs');
const HTTP_PORT = 8080;
const HTTPS_PORT = 8443;
const options = {
key: fs.readFileSync('./rootca.key'),
cert: fs.readFileSync('./rootca.crt')
};
const app = express();
// Default route for server status
app.get('/', (req, res) => {
res.json({ message: `Server is running on port ${req.secure ? HTTPS_PORT : HTTP_PORT}` });
});
// Create an HTTP server.
http.createServer(app).listen(HTTP_PORT);
// Create an HTTPS server.
https.createServer(options, app).listen(HTTPS_PORT);
https://cinema4dr12.tistory.com/984
첨부파일
- Node.js HTTPS 설정하기.pdf (1.7M) 0회 다운로드 | DATE : 2023-03-20 16:13:20
- private.pem (887byte) 1회 다운로드 | DATE : 2023-03-22 12:10:19
- public2.pem (936byte) 1회 다운로드 | DATE : 2023-03-22 12:10:19
관련링크
- https://freestrokes.tistory.com/154 4667회 연결
- https://youtu.be/EFIK5gef_Es 2893회 연결
댓글목록 0
등록된 댓글이 없습니다.