feature: allow non-secure connections

- default to secure
- parameterize via env var
This commit is contained in:
Asif Bacchus 2021-07-23 13:31:01 -06:00
parent ee38b2468e
commit 8f35aaef11
3 changed files with 24 additions and 5 deletions

View File

@ -39,6 +39,7 @@ ENV LR_EXTS="html,xml,css,js,jsx,ts,tsx,php,py"
ENV LR_EXCLUDE=".git/,.svn/,.vscode/,.idea/"
ENV LR_DELAY=500
ENV LR_DEBUG=true
ENV LR_HTTPS=true
# install livereload npm as node user then switch back to root user
USER node

View File

@ -6,21 +6,36 @@
# functions
certificateGenerateNew() {
certificateCheckEnabled
printf "\nGenerating new self-signed certificate:\n"
printf "Exporting new certificate:\n"
exit 0
}
certificateShow() {
certificateCheckEnabled
printf "\nCurrently loaded certificate:\n"
exit 0
}
certificateExport() {
certificateCheckEnabled
printf "\nExporting currently loaded certificate:\n"
exit 0
}
certificateCheckEnabled() {
httpsEnabled="$(convertCaseUpper "$LR_HTTPS")"
if [ "$httpsEnabled" != "TRUE" ]; then
printf "\nSSL/TLS not enabled. Please set LR_HTTPS=TRUE if you want to enable SSL/TLS.\n"
exit 1
fi
}
convertCaseUpper() {
printf "%s" "$1" | tr "[:lower:]" "[:upper:]"
}
# default variable values
doCertExport=0
doCertNew=0

View File

@ -4,13 +4,8 @@
let livereload = require('livereload');
// set createServer options
const https = require('https');
const fs = require('fs');
const options = {
https: {
cert: fs.readFileSync('/certs/fullchain.pem'),
key: fs.readFileSync('/certs/privkey.pem')
},
port: process.env.LR_PORT,
exts: process.env.LR_EXTS,
exclusions: process.env.LR_EXCLUDE,
@ -19,6 +14,14 @@ const options = {
debug: process.env.LR_DEBUG
};
if (process.env.LR_HTTPS) {
options.https = {
cert: fs.readFileSync('/certs/fullchain.pem'),
key: fs.readFileSync('/certs/privkey.pem')
};
}
// start server
let server = livereload.createServer(options);
server.watch('/watch')