b403d596 by Rafal Wilinski

Add Manual HTTPS support

1 parent cd5c09cb
...@@ -16,7 +16,8 @@ Monitor can be configured by passing options object into `expressMonitor` constr ...@@ -16,7 +16,8 @@ Monitor can be configured by passing options object into `expressMonitor` constr
16 Default config: 16 Default config:
17 ``` 17 ```
18 path: '/status', 18 path: '/status',
19 socketPort: 41338, // Port for Socket.io communication 19 socketPort: 41338, // Port for Socket.io communication,
20 useHttps: false, // Force HTTPS protocol instead of HTTP
20 spans: [{ 21 spans: [{
21 interval: 1, // Every second 22 interval: 1, // Every second
22 retention: 60 // Keep 60 datapoints in memory 23 retention: 60 // Keep 60 datapoints in memory
......
...@@ -136,7 +136,7 @@ ...@@ -136,7 +136,7 @@
136 Chart.defaults.global.elements.line.borderColor = "rgba(0,0,0,0.9)"; 136 Chart.defaults.global.elements.line.borderColor = "rgba(0,0,0,0.9)";
137 Chart.defaults.global.elements.line.borderWidth = 2; 137 Chart.defaults.global.elements.line.borderWidth = 2;
138 138
139 var socket = io(window.location.protocol + '//' + window.location.hostname + ':{{port}}'); 139 var socket = io('{{protocol}}'+ '://' + window.location.hostname + ':{{port}}');
140 var defaultSpan = 0; 140 var defaultSpan = 0;
141 var spans = []; 141 var spans = [];
142 142
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
10 const defaultConfig = { 10 const defaultConfig = {
11 socketPort: 41338, 11 socketPort: 41338,
12 path: '/status', 12 path: '/status',
13 useHttps: false,
13 spans: [{ 14 spans: [{
14 interval: 1, 15 interval: 1,
15 retention: 60 16 retention: 60
...@@ -85,7 +86,7 @@ ...@@ -85,7 +86,7 @@
85 fs.readFile(path.join(__dirname, 'index.html'), 'utf8', (err,data) => { 86 fs.readFile(path.join(__dirname, 'index.html'), 'utf8', (err,data) => {
86 if (err) throw new Error(err); 87 if (err) throw new Error(err);
87 88
88 var result = data.replace(/{{port}}/g, config.socketPort); 89 var result = data.replace(/{{port}}/g, config.socketPort).replace(/{{protocol}}/g, config.useHttps ? 'https' : 'http');
89 90
90 fs.writeFile(path.join(__dirname, 'index.rendered.html'), result, 'utf8', (err) => { 91 fs.writeFile(path.join(__dirname, 'index.rendered.html'), result, 'utf8', (err) => {
91 if (err) throw new Error(err); 92 if (err) throw new Error(err);
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!