Docker에 간단한 HTTPS 서버 구축 (Node.js)
환경
컨테이너 만들기
docker run --name server -itd -p 8443:8443 alpine

컨테이너에 로그인
docker exec -it server /bin/ash
ash는 alpine에서 사용되는 쉘

필요한 모듈 설치
1.alpine 패키지 리포지토리에서 최신 색인 검색
apk update

2.Node.js 설치
apk add nodejs

3.npm 설치
apk add npm

4.openssl 설치(HTTPS 인증서 작성에 필요)
apk add openssl

작업 디렉토리 만들기
mkdir work
cd work

인증서 파일(pfx 파일) 만들기
openssl genrsa 2048 > mysslserver.key
openssl req -new -key mysslserver.key -subj "/C=JP/ST=Tokyo-to/L=Shibuya/O=Company Name/OU=IT dept./CN=Company Dept CA" > mysslserver.csr
openssl x509 -days 3650 -req -signkey mysslserver.key < mysslserver.csr > mysslserver.crt
openssl pkcs12 -export -inkey mysslserver.key -in mysslserver.crt > mysslserver.pfx

HTTPS 서버 생성
vi로 작성한다.
https.js
https = require('https');
fs = require('fs');
port=8443;
https.createServer({pfx: fs.readFileSync('mysslserver.pfx')}, function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(port);
console.log('Server running at port:' + port);
서버 시작
node https.js

소통 확인
https : localhost : 8443으로 이동하여 Hello World가 표시되면 OK

Reference
이 문제에 관하여(Docker에 간단한 HTTPS 서버 구축 (Node.js)), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/sndstudy/items/f7b183042adaa71d057f텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)