-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtst_https.js
34 lines (27 loc) · 874 Bytes
/
tst_https.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Dependencies
const fs = require('fs');
const http = require('http');
const https = require('https');
const express = require('express');
const app = express();
// Certificate
const privateKey = fs.readFileSync('/home/emp-03/corpdesk_net_pk_01.key', 'utf8');
const certificate = fs.readFileSync('/home/emp-03/corpdesk_net.crt', 'utf8');
//const ca = fs.readFileSync('/etc/letsencrypt/live/yourdomain.com/chain.pem', 'utf8');
const credentials = {
key: privateKey,
cert: certificate
//ca: ca
};
app.use((req, res) => {
res.send('Hello there !');
});
// Starting both http & https servers
const httpServer = http.createServer(app);
const httpsServer = https.createServer(credentials, app);
httpServer.listen(3003, () => {
console.log('HTTP Server running on port 3003');
});
httpsServer.listen(3004, () => {
console.log('HTTPS Server running on port 3004');
});