Skip to content

Instantly share code, notes, and snippets.

@doyle-flutter
Last active February 21, 2021 13:43
Show Gist options
  • Save doyle-flutter/06563ce49377c86b013f98923249f1fc to your computer and use it in GitHub Desktop.
Save doyle-flutter/06563ce49377c86b013f98923249f1fc to your computer and use it in GitHub Desktop.
webRTC 서버연결
// * Node.js 개발 테스트용 HTTPS pem 생성
// : 해당 서버 파일의 위치에 keys 폴더를 생성하고 아래의 내용으로 생성한 pem을 담아주세요.
// > openssl genrsa 1024 > private.pem
// > openssl req -x509 -new -key private.pem > public.pem
// * npm i -s expreess https path
var express = require('express'),
app = express(),
fs = require('fs'),
path = require('path'),
https = require('https'),
key = fs.readFileSync(path.join(__dirname,'./keys/private.pem')), // OpenSSL
cert = fs.readFileSync(path.join(__dirname, './keys/public.pem')), // OpenSSL
server = https.createServer({ key, cert, requestCert: false, rejectUnauthorized: false, },app);
app.get('/', (req, res) => res.redirect(`/123`));
app.get('/:room', (req, res) => res.sendFile(path.join(__dirname, './views/room.html')));
server.listen(443);
app.listen(3001);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment