update for v2.x
This commit is contained in:
parent
aec233397e
commit
24f4bbf6ea
39
README.md
39
README.md
|
@ -3,6 +3,7 @@
|
|||
| [letsencrypt (library)](https://github.com/Daplie/node-letsencrypt)
|
||||
| [letsencrypt-cli](https://github.com/Daplie/letsencrypt-cli)
|
||||
| [letsencrypt-express](https://github.com/Daplie/letsencrypt-express)
|
||||
| [letsencrypt-cluster](https://github.com/Daplie/letsencrypt-cluster)
|
||||
| **letsencrypt-koa**
|
||||
| [letsencrypt-hapi](https://github.com/Daplie/letsencrypt-hapi)
|
||||
|
|
||||
|
@ -22,7 +23,7 @@ All you have to do is start the webserver and then visit it at it's domain name.
|
|||
## Install
|
||||
|
||||
```
|
||||
npm install --save letsencrypt-express@1.x
|
||||
npm install --save letsencrypt-express@2.x
|
||||
```
|
||||
|
||||
*Pay no attention to the man behind the curtain.* (just ignore that the name of the module is letsencrypt-express)
|
||||
|
@ -32,20 +33,20 @@ npm install --save letsencrypt-express@1.x
|
|||
```javascript
|
||||
'use strict';
|
||||
|
||||
/* Note: using staging server url, remove .testing() for production
|
||||
Using .testing() will overwrite the debug flag with true */
|
||||
var LEX = require('letsencrypt-express').testing();
|
||||
var le = require('letsencrypt-express').create({
|
||||
server: 'staging' // in production use 'https://acme-v01.api.letsencrypt.org/directory'
|
||||
|
||||
, configDir: require('os').homedir() + '/letsencrypt/etc'
|
||||
|
||||
var lex = LEX.create({
|
||||
configDir: require('os').homedir() + '/letsencrypt/etc'
|
||||
, approveRegistration: function (hostname, cb) { // leave `null` to disable automatic registration
|
||||
// Note: this is the place to check your database to get the user associated with this domain
|
||||
cb(null, {
|
||||
domains: [hostname]
|
||||
, email: 'CHANGE_ME' // user@example.com
|
||||
, agreeTos: true
|
||||
});
|
||||
, approveDomains: function (opts, certs, cb) {
|
||||
opts.domains = certs && certs.altnames || opts.domains;
|
||||
opts.email = 'john.doe@example.com' // CHANGE ME
|
||||
opts.agreeTos = true;
|
||||
|
||||
cb(null, { options: opts, certs: certs });
|
||||
}
|
||||
|
||||
, debug: true
|
||||
});
|
||||
```
|
||||
|
||||
|
@ -55,6 +56,7 @@ WARNING: If you don't do any checks and simply complete `approveRegistration` ca
|
|||
npm install -g letsencrypt-cli
|
||||
|
||||
letsencrypt certonly --standalone \
|
||||
--server 'https://acme-v01.api.letsencrypt.org/directory' \
|
||||
--config-dir ~/letsencrypt/etc \
|
||||
--agree-tos --domains example.com --email user@example.com
|
||||
|
||||
|
@ -68,20 +70,21 @@ var http = require('http');
|
|||
var https = require('spdy');
|
||||
var koa = require('koa');
|
||||
var app = koa();
|
||||
var redirectHttps = koa().use(require('koa-sslify')()).callback();
|
||||
|
||||
app.use(function *() {
|
||||
this.body = 'Hello World';
|
||||
});
|
||||
|
||||
var server = https.createServer(lex.httpsOptions, LEX.createAcmeResponder(lex, app.callback()));
|
||||
var redirectServer = http.createServer(LEX.createAcmeResponder(lex, redirectHttps)));
|
||||
var server = https.createServer(le.httpsOptions, le.middleware(app.callback()));
|
||||
|
||||
server.listen(443, function () {
|
||||
console.log('Listening at https://localhost:' + this.address().port);
|
||||
});
|
||||
|
||||
redirectServer.listen(80, function () {
|
||||
console.log('Redirecting insecure traffic from http://localhost:' + this.address().port + ' to https');
|
||||
|
||||
var http = require('http');
|
||||
var redirectHttps = koa().use(require('koa-sslify')()).callback();
|
||||
http.createServer(le.middleware(redirectHttps)).listen(80, function () {
|
||||
console.log('handle ACME http-01 challenge and redirect to https');
|
||||
});
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue