Update README.md
This commit is contained in:
parent
55b85c318e
commit
b34ad0d597
30
README.md
30
README.md
|
@ -86,6 +86,10 @@ Let's say you want to redirect all http to https.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
var LEX = require('letsencrypt-express');
|
var LEX = require('letsencrypt-express');
|
||||||
|
var http = require('http');
|
||||||
|
var https = require('http2');
|
||||||
|
// NOTE: you could use the old https module if for some reason you don't want to support modern browsers
|
||||||
|
|
||||||
var lex = LEX.create({
|
var lex = LEX.create({
|
||||||
configDir: __dirname + '/letsencrypt.config'
|
configDir: __dirname + '/letsencrypt.config'
|
||||||
, approveRegistration: function (hostname, cb) {
|
, approveRegistration: function (hostname, cb) {
|
||||||
|
@ -97,21 +101,25 @@ var lex = LEX.create({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function redirectHttp() {
|
||||||
|
http.createServer(LEX.createAcmeResponder(lex, function redirectHttps(req, res) {
|
||||||
|
res.setHeader('Location', 'https://' + req.headers.host + req.url);
|
||||||
|
res.end('<!-- Hello Developer Person! Please use HTTPS instead -->');
|
||||||
|
})).listen(80);
|
||||||
|
}
|
||||||
|
|
||||||
var http = require('http');
|
function serveHttps() {
|
||||||
http.createServer(LEX.createAcmeResponder(lex, function redirectHttps(req, res) {
|
var app = require('express')();
|
||||||
res.setHeader('Location', 'https://' + req.headers.host + req.url);
|
|
||||||
res.end('<!-- Hello Developer Person! Please use HTTPS instead -->');
|
|
||||||
})).listen(80);
|
|
||||||
|
|
||||||
|
app.use('/', function (req, res) {
|
||||||
|
res.end('Hello!');
|
||||||
|
});
|
||||||
|
|
||||||
var app = require('express')();
|
https.createServer(lex.httpsOptions, LEX.createAcmeResponder(lex, app)).listen(443);
|
||||||
app.use('/', function (req, res) {
|
}
|
||||||
res.end('Hello!');
|
|
||||||
});
|
|
||||||
|
|
||||||
var https = require('http2');
|
redirectHttp();
|
||||||
https.createServer(lex.httpsOptions, LEX.createAcmeResponder(lex, app)).listen(443);
|
serveHttps();
|
||||||
```
|
```
|
||||||
|
|
||||||
In short these are the only functions you need to be aware of:
|
In short these are the only functions you need to be aware of:
|
||||||
|
|
Loading…
Reference in New Issue