server.js 904 Bytes
Newer Older
Patrick's avatar
test    
Patrick committed
1

Patrick's avatar
test    
Patrick committed
2
3
4
5
const fs = require('fs');
const http = require('http');
const https = require('https');
const express = require('express');
Patrick's avatar
test    
Patrick committed
6

Patrick's avatar
test    
Patrick committed
7
const app = express();
Patrick's avatar
Patrick committed
8
9
10
11
12

// Certificate
const privateKey = fs.readFileSync('/etc/letsencrypt/live/umfrage.smartvillages.online/privkey.pem', 'utf8');
const certificate = fs.readFileSync('/etc/letsencrypt/live/umfrage.smartvillages.online/cert.pem', 'utf8');
const ca = fs.readFileSync('/etc/letsencrypt/live/umfrage.smartvillages.online/chain.pem', 'utf8');
Patrick's avatar
test    
Patrick committed
13

Patrick's avatar
Patrick committed
14
15
16
17
18
19
const credentials = {
	key: privateKey,
	cert: certificate,
	ca: ca
};

Patrick's avatar
test    
Patrick committed
20
app.use(express.static('vcm'));
Patrick's avatar
Patrick committed
21

Patrick's avatar
Patrick committed
22
23
24
25
// Starting both http & https servers
const httpServer = http.createServer(app);
const httpsServer = https.createServer(credentials, app);

Patrick's avatar
test    
Patrick committed
26
27
httpServer.listen(8083, () => {
	console.log('HTTP Server running on port 80');
Patrick's avatar
test    
Patrick committed
28
29
});

Patrick's avatar
test    
Patrick committed
30
31
httpsServer.listen(8084, () => {
	console.log('HTTPS Server running on port 443');
Patrick's avatar
Patrick committed
32
33
});

Patrick's avatar
test    
Patrick committed
34
35