1 | express-enforces-ssl
|
2 | ==============
|
3 |
|
4 | This simple module enforces HTTPS connections on any incoming requests. In case of a non-encrypted HTTP request, express-enforces-ssl automatically redirects to an HTTPS address using a 301 permanent redirect.
|
5 |
|
6 | express-enforces-ssl also works behind reverse proxies (load balancers) as they are for example used by Heroku and nodejitsu. In such cases, however, the `trustProxy` parameter has to be set (see below)
|
7 |
|
8 | ### Usage
|
9 |
|
10 | First, install the module:
|
11 |
|
12 | ```
|
13 | $ npm install express-enforces-ssl --save
|
14 | ```
|
15 |
|
16 | Afterwards, require the module and *use* the `HTTPS()` method:
|
17 | ```javascript
|
18 | var express = require('express');
|
19 | var http = require('http');
|
20 | var express_enforces_ssl = require('express-enforces-ssl');
|
21 |
|
22 | var app = express();
|
23 |
|
24 | app.enable('trust proxy');
|
25 |
|
26 | app.use(express_enforces_ssl());
|
27 |
|
28 | /*
|
29 | Routes Here
|
30 | */
|
31 |
|
32 | http.createServer(app).listen(app.get('port'), function() {
|
33 | console.log('Express server listening on port ' + app.get('port'));
|
34 | });
|
35 |
|
36 | ```
|
37 |
|
38 | LICENCE
|
39 |
|
40 | MIT
|