Redirecting http to https

Signed-off-by: Walamana <joniogerg@gmail.com>
This commit is contained in:
2017-11-27 18:27:05 +01:00
parent 96500de584
commit c056d02790
63 changed files with 4077 additions and 0 deletions

34
node_modules/express-force-ssl/examples/example.js generated vendored Normal file
View File

@@ -0,0 +1,34 @@
var express = require('express')
, forceSSL = require('./../index')
, fs = require('fs')
, http = require('http')
, https = require('https')
;
var ssl_options = {
key: fs.readFileSync('./test/keys/localhost.key'),
cert: fs.readFileSync('./test/keys/localhost.crt'),
ca: fs.readFileSync('./test/keys/localhost.crt')
};
var app = express();
var server = http.createServer(app);
var secureServer = https.createServer(ssl_options, app);
app.get('/', function(req, res){
res.json({msg: 'accessible by http'});
});
app.get('/ssl', forceSSL, function(req, res){
res.json({msg: 'only https'});
});
app.get('/ssl/deep/route/:id', forceSSL, function(req, res){
var host = req.headers.host.split(':');
var port = host.length > 1 ? host[1] : 'default port';
res.json({msg: 'only https, port: ' + port, id: req.param('id')});
});
app.set('httpsPort', 8443);
secureServer.listen(8443);
server.listen(8080);