-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
35 lines (27 loc) · 1.01 KB
/
app.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
33
34
35
var express = require('express');
var http = require('http');
var https = require('https');
var fs = require('fs');
var compression = require('compression');
var app = express();
app.use(compression());
app.use(function(req, res, next) {
if(!req.secure) {
return res.redirect(['https://', req.hostname, ':', app.https_port, req.originalUrl].join(''));
}
next();
});
app.use(express.static(__dirname + '/public'));
app.get('*', function(req, res) {
res.sendFile(__dirname + '/public/index.html');
});
app.https_port = process.env.ASHEVILLE_WEB_HTTPS_PORT;
app.http_port = process.env.ASHEVILLE_WEB_HTTP_PORT;
https.createServer({
key: fs.readFileSync(process.env.ASHEVILLE_WEB_SSL_KEY, 'utf8'),
cert: fs.readFileSync(process.env.ASHEVILLE_WEB_SSL_CRT, 'utf8'),
ca: fs.readFileSync(process.env.ASHEVILLE_WEB_SSL_INT_CRT, 'utf8')
}, app).listen(app.https_port);
http.createServer(app).listen(app.http_port);
console.info('https listening on', app.https_port);
console.info('http listening on', app.http_port);