-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.js
32 lines (29 loc) · 857 Bytes
/
server.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
// Imports
const fs = require('fs')
const MjpegProxy = require('mjpeg-proxy').MjpegProxy
const https = require('https')
const path = require('path')
const express = require('express')
const app = express()
app.use(express.static(path.join(__dirname, 'dist')))
// Config
const STREAMURL = 'http://192.168.68.111/mjpg/1/video.mjpg'
const CERTPATH = '/etc/letsencrypt/live/kitese.duckdns.org/'
const PORT = 8080;
// Routes
app.get('/stream', new MjpegProxy(STREAMURL).proxyRequest);
app.get('/', (req, res) => {
res.sendFile(__dirname, '/dist/index.html');
});
// Setup
try {
https.createServer({
key: fs.readFileSync(CERTPATH + 'privkey.pem'),
cert: fs.readFileSync(CERTPATH + 'cert.pem'),
ca: fs.readFileSync(CERTPATH + 'fullchain.pem')
}, app).listen(PORT, () => {
console.log('Listening...')
})
} catch (e) {
console.log(e);
}