Implement https/ssl
This commit is contained in:
parent
5a009f9d00
commit
f62b580d46
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,3 +1,5 @@
|
|||||||
/downloads/
|
/downloads/
|
||||||
*index-*.html
|
*index-*.html
|
||||||
/node_modules/
|
/node_modules/
|
||||||
|
*.pem
|
||||||
|
|
||||||
|
@ -6,3 +6,10 @@ PASSWD_HASH = 'a3c1443b087cf5338d3696f6029fdf791ee4829a27e19c9f257a06ca0d88b5b51
|
|||||||
# Sessions stay valid this many seconds, if inactive. Default: 600 (=10 minutes)
|
# Sessions stay valid this many seconds, if inactive. Default: 600 (=10 minutes)
|
||||||
SESSION_DURATION = 600
|
SESSION_DURATION = 600
|
||||||
|
|
||||||
|
# The port the webserver runs on
|
||||||
|
WEBSERVER_PORT = 443
|
||||||
|
|
||||||
|
# SSL key and certificate (you have to generate these yourself)
|
||||||
|
SSL_KEY_FILE = "key.pem"
|
||||||
|
SSL_CERT_FILE = "cert.pem"
|
||||||
|
|
||||||
|
8
package-lock.json
generated
8
package-lock.json
generated
@ -45,10 +45,10 @@
|
|||||||
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz",
|
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz",
|
||||||
"integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA=="
|
"integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA=="
|
||||||
},
|
},
|
||||||
"http": {
|
"https": {
|
||||||
"version": "0.0.1-security",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/http/-/http-0.0.1-security.tgz",
|
"resolved": "https://registry.npmjs.org/https/-/https-1.0.0.tgz",
|
||||||
"integrity": "sha512-RnDvP10Ty9FxqOtPZuxtebw1j4L/WiqNMDtuc1YMH1XQm5TgDRaR1G9u8upL6KD1bXHSp9eSXo/ED+8Q7FAr+g=="
|
"integrity": "sha1-PDfHrhqO65ZpBKKtHpdaGUt+06Q="
|
||||||
},
|
},
|
||||||
"imurmurhash": {
|
"imurmurhash": {
|
||||||
"version": "0.1.4",
|
"version": "0.1.4",
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
"license": "BSD-2-Clause",
|
"license": "BSD-2-Clause",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"crypto": "^1.0.1",
|
"crypto": "^1.0.1",
|
||||||
"http": "0.0.1-security",
|
"https": "^1.0.0",
|
||||||
"querystring": "^0.2.1",
|
"querystring": "^0.2.1",
|
||||||
"session-file-store": "^1.5.0",
|
"session-file-store": "^1.5.0",
|
||||||
"toml": "^3.0.0"
|
"toml": "^3.0.0"
|
||||||
|
10
readme.md
Normal file
10
readme.md
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# Sellery
|
||||||
|
|
||||||
|
## How to generate your ssl pem files:
|
||||||
|
```sh
|
||||||
|
openssl genrsa -out key.pem
|
||||||
|
openssl req -new -key key.pem -out csr.pem
|
||||||
|
openssl x509 -req -days 9999 -in csr.pem -signkey key.pem -out cert.pem
|
||||||
|
rm csr.pem
|
||||||
|
```
|
||||||
|
|
14
server.js
14
server.js
@ -1,4 +1,4 @@
|
|||||||
var http = require('http');
|
var https = require('https');
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
var querystring = require('querystring');
|
var querystring = require('querystring');
|
||||||
@ -203,7 +203,12 @@ function serverStaticFiles(request, response) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var server = http.createServer(function (request, response) {
|
const serverOptions = {
|
||||||
|
key: fs.readFileSync(config.SSL_KEY_FILE),
|
||||||
|
cert: fs.readFileSync(config.SSL_CERT_FILE)
|
||||||
|
};
|
||||||
|
|
||||||
|
var server = https.createServer(serverOptions, function (request, response) {
|
||||||
// Handle requests here...
|
// Handle requests here...
|
||||||
console.log(request.headers.referer);
|
console.log(request.headers.referer);
|
||||||
|
|
||||||
@ -230,7 +235,6 @@ var server = http.createServer(function (request, response) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const port = 80;
|
server.listen(config.WEBSERVER_PORT);
|
||||||
server.listen(port);
|
console.log('Node.js sellery server running and listening to port ' + config.WEBSERVER_PORT);
|
||||||
console.log('Node.js sellery server running and listening to port ' + port);
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user