websocket https

This commit is contained in:
barwie2@st.amu.edu.pl 2020-03-08 19:07:00 +01:00
parent 49cc7930d3
commit e181c4044d

View File

@ -1,5 +1,5 @@
const WebSocket = require('ws');
var http = require('http');
var https = require('https');
var websocket_port = 8888;
const wss = new WebSocket.Server({port: websocket_port});
@ -11,7 +11,10 @@ wss.on('connection', function connection(ws) {
lookup[ws.protocol] = ws;
});
var server = http.createServer(function (request, response) {
var server = https.createServer({
cert: fs.readFileSync('/etc/letsencrypt/live/atcheck.projektstudencki.pl/fullchain.pem'),
key: fs.readFileSync('/etc/letsencrypt/live/atcheck.projektstudencki.pl/key.pem')
}, function (request, response) {
response.writeHead(200, {"Content-Type": "text\plain"});
request.setEncoding('utf8');