Node.js HTTPS 설정하기
페이지 정보
본문
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
4686회 연결 -
https://youtu.be/EFIK5gef_Es
2905회 연결
- 이전글node oracledb 설치 후 실행시 오류 DPI-1047 윈도우 환경 windows 23.03.21
- 다음글node oracle 연동 및 mvc 참고자료 23.03.19
댓글목록
등록된 댓글이 없습니다.