|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+var fs = require('fs');
|
|
|
2
|
+var https = require('https');
|
|
|
3
|
+var express = require('express');
|
|
|
4
|
+var path = require('path');
|
|
|
5
|
+var forceSSL = require('express-force-ssl');
|
|
|
6
|
+var app = express();
|
|
|
7
|
+
|
|
|
8
|
+app.use(forceSSL);
|
|
|
9
|
+app.use('/', express.static('../www/'));
|
|
|
10
|
+app.use(function (req,res,next) {
|
|
|
11
|
+ res.status(404).sendFile(path.resolve('../www_res/404/index.html'));
|
|
|
12
|
+});
|
|
|
13
|
+
|
|
|
14
|
+var prkey = fs.readFileSync('key.pem');
|
|
|
15
|
+var certi = fs.readFileSync('cert.pem');
|
|
|
16
|
+
|
|
|
17
|
+https.createServer({
|
|
|
18
|
+ key: prkey,
|
|
|
19
|
+ cert: certi
|
|
|
20
|
+}, app).listen(443, function() {
|
|
|
21
|
+ console.log('Now accepting HTTPS connections on port 443.');
|
|
|
22
|
+});
|
|
|
23
|
+
|
|
|
24
|
+app.listen(80, function () {
|
|
|
25
|
+ console.log('Now accepting HTTP connections on port 80.');
|
|
|
26
|
+});
|