Matt Coles 9 anni fa
commit
b154dac87d
3 ha cambiato i file con 43 aggiunte e 0 eliminazioni
  1. 2 0
      .gitignore
  2. 26 0
      index.js
  3. 15 0
      package.json

+ 2 - 0
.gitignore

@@ -0,0 +1,2 @@
1
+*.pem
2
+node_modules/

+ 26 - 0
index.js

@@ -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
+});

+ 15 - 0
package.json

@@ -0,0 +1,15 @@
1
+{
2
+  "name": "portfolio",
3
+  "version": "1.0.0",
4
+  "description": "",
5
+  "main": "index.js",
6
+  "scripts": {
7
+    "test": "echo nah"
8
+  },
9
+  "author": "Matt Coles",
10
+  "license": "MIT",
11
+  "dependencies": {
12
+    "express": "^4.13.4",
13
+    "express-force-ssl": "^0.3.2"
14
+  }
15
+}