Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bin/www: add https support #61

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions bin/www
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,29 @@
var app = require('../app');
var debug = require('debug')('dhcpd-warrior:server');
var http = require('http');
var https = require('https');
var fs = require('fs');

/**
* Get port from environment and store in Express.
*/

var isHttps = normalizePort(app.glass_config.port) === 443;
var ca = app.glass_config.ca ? fs.readFileSync(app.glass_config.ca) : undefined;
var dhparams = app.glass_config.dhparams ? fs.readFileSync(app.glass_config.dhparams) : undefined;
var cert = fs.readFileSync(app.glass_config.cert);
var key = fs.readFileSync(app.glass_config.key);
var options = { key, cert, ca, dhparams };

var port = normalizePort(process.env.PORT || app.glass_config.port || '3000');
var interface = app.glass_config.host || '0.0.0.0';
app.set('port', port);

/**
* Create HTTP server.
* Create HTTP or HTTPS server.
*/

var server = http.createServer(app);
var server = isHttps ? https.createServer(options, app) : http.createServer(app);

/**
* Listen on provided port, on all network interfaces.
Expand Down
52 changes: 41 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"express": "^4.16.3",
"express-ipfilter": "^0.3.1",
"forever": "^0.15.3",
"fs": "0.0.1-security",
"https": "^1.0.0",
"humanize": "0.0.9",
"jade": "~1.11.0",
"jsonfile": "^3.0.1",
Expand Down
14 changes: 14 additions & 0 deletions setup/glass-isc-dhcp.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
Description=Glass ISC DHCP-Server Monitor
After=syslog.target network.target

[Service]
Environment="NODE_ENV=production"
WorkingDirectory=/opt/glass-isc-dhcp
ExecStart=/usr/bin/node bin/www
Type=simple
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.taraget