server.js 1.05 KB
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
Patrick committed
6
const bodyParser = require('body-parser')
Patrick's avatar
test    
Patrick committed
7

Patrick's avatar
Patrick committed
8
9
const request = require('ajax-request');

Patrick's avatar
test    
Patrick committed
10

Patrick's avatar
test    
Patrick committed
11
const app = express();
Patrick's avatar
test    
Patrick committed
12
13
app.use(bodyParser.urlencoded({ extended: false })) 
app.use(bodyParser.json())
Patrick's avatar
Patrick committed
14
15
16
17
// 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
18

Patrick's avatar
Patrick committed
19
20
21
22
23
24
const credentials = {
	key: privateKey,
	cert: certificate,
	ca: ca
};

Patrick's avatar
test    
Patrick committed
25
app.use(express.static('vcm'));
Patrick's avatar
Patrick committed
26

Patrick's avatar
Patrick committed
27
// Starting both http & https servers
Patrick's avatar
Patrick committed
28
// const httpServer = http.createServer(app);
Patrick's avatar
Patrick committed
29
30
const httpsServer = https.createServer(credentials, app);

Patrick's avatar
Patrick committed
31
32
33
// httpServer.listen(8083, () => {
// 	console.log('HTTP Server running on port 80');
// });
Patrick's avatar
test    
Patrick committed
34

Patrick's avatar
Patrick committed
35
httpsServer.listen(8081, () => {
Patrick's avatar
test    
Patrick committed
36
	console.log('HTTPS Server running on port 443');
Patrick's avatar
Patrick committed
37
38
});