Compare commits
5 Commits
Author | SHA1 | Date |
---|---|---|
AJ ONeal | a9ca9b5508 | |
AJ ONeal | 08b10b08cf | |
AJ ONeal | b75d9fceac | |
AJ ONeal | df8e0ecefa | |
AJ ONeal | 72fd25d54f |
|
@ -2,10 +2,11 @@
|
||||||
ATTENTION!
|
ATTENTION!
|
||||||
==========
|
==========
|
||||||
|
|
||||||
Please report issues at https://github.com/Daplie/letsencrypt-express
|
Please report issues at https://git.coolaj86.com/coolaj86/greenlock-express.js
|
||||||
|
|
||||||
========
|
========
|
||||||
ACHTUNG!
|
ACHTUNG!
|
||||||
========
|
========
|
||||||
|
|
||||||
Bitte melden Sie Probleme bei https://github.com/Daplie/letsencrypt-express
|
Bitte melden Sie Probleme bei
|
||||||
|
https://git.coolaj86.com/coolaj86/greenlock-express.js
|
||||||
|
|
31
LICENSE
31
LICENSE
|
@ -1,3 +1,32 @@
|
||||||
|
At your option you may choose either of the following licenses:
|
||||||
|
|
||||||
|
* The MIT License (MIT)
|
||||||
|
* The Apache License 2.0 (Apache-2.0)
|
||||||
|
|
||||||
|
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2016-2018 AJ ONeal
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
Apache License
|
Apache License
|
||||||
Version 2.0, January 2004
|
Version 2.0, January 2004
|
||||||
http://www.apache.org/licenses/
|
http://www.apache.org/licenses/
|
||||||
|
@ -186,7 +215,7 @@
|
||||||
same "printed page" as the copyright notice for easier
|
same "printed page" as the copyright notice for easier
|
||||||
identification within third-party archives.
|
identification within third-party archives.
|
||||||
|
|
||||||
Copyright {yyyy} {name of copyright owner}
|
Copyright 2015 AJ ONeal
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|
77
README.md
77
README.md
|
@ -1,6 +1,6 @@
|
||||||
# Greenlock™ for Koa
|
# Greenlock™ for rill
|
||||||
|
|
||||||
An Automated HTTPS ACME client (Let's Encrypt v2) for Koa
|
An Automated HTTPS ACME client (Let's Encrypt v2) for rill
|
||||||
|
|
||||||
Greenlock™ for
|
Greenlock™ for
|
||||||
[Browsers](https://git.coolaj86.com/coolaj86/greenlock.html),
|
[Browsers](https://git.coolaj86.com/coolaj86/greenlock.html),
|
||||||
|
@ -9,8 +9,8 @@ Greenlock™ for
|
||||||
[Express.js](https://git.coolaj86.com/coolaj86/greenlock-express.js),
|
[Express.js](https://git.coolaj86.com/coolaj86/greenlock-express.js),
|
||||||
[Node.js Cluster](https://git.coolaj86.com/coolaj86/greenlock-cluster.js),
|
[Node.js Cluster](https://git.coolaj86.com/coolaj86/greenlock-cluster.js),
|
||||||
[hapi](https://git.coolaj86.com/coolaj86/greenlock-hapi.js),
|
[hapi](https://git.coolaj86.com/coolaj86/greenlock-hapi.js),
|
||||||
**Koa**,
|
[Koa](https://git.coolaj86.com/coolaj86/greenlock-koa.js),
|
||||||
and [rill](https://git.coolaj86.com/coolaj86/greenlock-rill.js)
|
and **rill**
|
||||||
| Sponsered by [ppl](https://ppl.family)
|
| Sponsered by [ppl](https://ppl.family)
|
||||||
|
|
||||||
Features
|
Features
|
||||||
|
@ -29,7 +29,7 @@ which works with any middleware system.
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
```
|
```
|
||||||
npm install --save greenlock-koa@2.x
|
npm install --save greenlock-rill@2.x
|
||||||
```
|
```
|
||||||
|
|
||||||
QuickStart
|
QuickStart
|
||||||
|
@ -42,7 +42,7 @@ QuickStart
|
||||||
// Greenlock Setup //
|
// Greenlock Setup //
|
||||||
//////////////////////
|
//////////////////////
|
||||||
|
|
||||||
var greenlock = require('greenlock-koa').create({
|
var greenlock = require('greenlock-rill').create({
|
||||||
version: 'draft-11' // Let's Encrypt v2
|
version: 'draft-11' // Let's Encrypt v2
|
||||||
// You MUST change this to 'https://acme-v02.api.letsencrypt.org/directory' in production
|
// You MUST change this to 'https://acme-v02.api.letsencrypt.org/directory' in production
|
||||||
, server: 'https://acme-staging-v02.api.letsencrypt.org/directory'
|
, server: 'https://acme-staging-v02.api.letsencrypt.org/directory'
|
||||||
|
@ -61,21 +61,21 @@ var greenlock = require('greenlock-koa').create({
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
//////////////////
|
///////////////////
|
||||||
// Just add Koa //
|
// Just add rill //
|
||||||
//////////////////
|
///////////////////
|
||||||
|
|
||||||
var http = require('http');
|
var http = require('http');
|
||||||
var https = require('https');
|
var https = require('https');
|
||||||
var koa = require('koa');
|
var Rill = require('rill');
|
||||||
var app = koa();
|
var app = new Rill();
|
||||||
|
|
||||||
app.use(function *() {
|
app.use(({ req, res }, next)=> {
|
||||||
this.body = 'Hello World';
|
res.body = 'Hello, World!';
|
||||||
});
|
});
|
||||||
|
|
||||||
// https server
|
// https server
|
||||||
var server = https.createServer(greenlock.tlsOptions, greenlock.middleware(app.callback()));
|
var server = https.createServer(greenlock.tlsOptions, greenlock.middleware(app.handler()));
|
||||||
|
|
||||||
server.listen(443, function () {
|
server.listen(443, function () {
|
||||||
console.log('Listening at https://localhost:' + this.address().port);
|
console.log('Listening at https://localhost:' + this.address().port);
|
||||||
|
@ -84,56 +84,31 @@ server.listen(443, function () {
|
||||||
|
|
||||||
// http redirect to https
|
// http redirect to https
|
||||||
var http = require('http');
|
var http = require('http');
|
||||||
var redirectHttps = koa().use(require('koa-sslify')()).callback();
|
var redirectHttps = require('redirect-https')();
|
||||||
http.createServer(greenlock.middleware(redirectHttps)).listen(80, function () {
|
http.createServer(greenlock.middleware(redirectHttps)).listen(80, function () {
|
||||||
console.log('Listening on port 80 to handle ACME http-01 challenge and redirect to https');
|
console.log('Listening on port 80 to handle ACME http-01 challenge and redirect to https');
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Usage & Troubleshooting
|
||||||
|
============================
|
||||||
|
|
||||||
|
See <https://git.coolaj86.com/coolaj86/greenlock-express.js>
|
||||||
|
|
||||||
Handling a dynamic list of domains
|
Handling a dynamic list of domains
|
||||||
========================
|
========================
|
||||||
|
|
||||||
If you handle multiple domains and you dynamically add new ones,
|
In the oversimplified exapmple above we handle a static list of domains.
|
||||||
you'll want to replace the static list of domains in `approveDomains`
|
If you add domains programmatically you'll want to use the `approveDomains`
|
||||||
with a function like this:
|
callback.
|
||||||
|
|
||||||
```js
|
|
||||||
function approveDomains(opts, certs, cb) {
|
|
||||||
// This is where you check your database and associated
|
|
||||||
// email addresses with domains and agreements and such
|
|
||||||
|
|
||||||
// The domains being approved for the first time are listed in opts.domains
|
|
||||||
// Certs being renewed are listed in certs.altnames
|
|
||||||
if (certs) {
|
|
||||||
opts.domains = certs.altnames;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Do something to
|
|
||||||
opts.email = 'john.doe@example.com';
|
|
||||||
opts.agreeTos = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
opts.communityMember = true;
|
|
||||||
|
|
||||||
// NOTE: you can also change other options such as `challengeType` and `challenge`
|
|
||||||
// opts.challengeType = 'http-01';
|
|
||||||
// opts.challenge = require('le-challenge-fs').create({});
|
|
||||||
|
|
||||||
cb(null, { options: opts, certs: certs });
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
**SECURITY**: Be careful with this.
|
**SECURITY**: Be careful with this.
|
||||||
If you don't check that the domains being requested are the domains you
|
If you don't check that the domains being requested are the domains you
|
||||||
allow an attacker can make you hit your rate limit for failed verification
|
allow an attacker can make you hit your rate limit for failed verification
|
||||||
attempts.
|
attempts.
|
||||||
|
|
||||||
See the
|
We have a
|
||||||
[vhost example](https://git.coolaj86.com/coolaj86/greenlock-express.js/src/branch/master/examples/vhost.js)
|
[vhost example](https://git.coolaj86.com/coolaj86/greenlock-express.js/src/branch/master/examples/vhost.js)
|
||||||
for an idea of how this is done.
|
that allows any domain for which there is a folder on the filesystem in a specific location.
|
||||||
|
|
||||||
|
See that example for an idea of how this is done.
|
||||||
More Usage & Troubleshooting
|
|
||||||
============================
|
|
||||||
|
|
||||||
See <https://git.coolaj86.com/coolaj86/greenlock-express.js>
|
|
||||||
|
|
2
index.js
2
index.js
|
@ -3,6 +3,6 @@
|
||||||
module.exports = require('greenlock-express');
|
module.exports = require('greenlock-express');
|
||||||
module.exports._greenlockExpressCreate = module.exports.create;
|
module.exports._greenlockExpressCreate = module.exports.create;
|
||||||
module.create = function (opts) {
|
module.create = function (opts) {
|
||||||
opts._communityPackage = opts._communityPackage || 'greenlock-koa';
|
opts._communityPackage = opts._communityPackage || 'greenlock-rill';
|
||||||
return module.exports._greenlockExpressCreate(opts);
|
return module.exports._greenlockExpressCreate(opts);
|
||||||
};
|
};
|
||||||
|
|
11
package.json
11
package.json
|
@ -1,14 +1,15 @@
|
||||||
{
|
{
|
||||||
"name": "greenlock-koa",
|
"name": "greenlock-rill",
|
||||||
"version": "2.1.2",
|
"homepage": "https://git.coolaj86.com/coolaj86/greenlock-rill.js",
|
||||||
"description": "An Automated HTTPS ACME client (Let's Encrypt v2) for Koa",
|
"version": "2.1.4",
|
||||||
|
"description": "An Automated HTTPS ACME client (Let's Encrypt v2) for rill",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://git.coolaj86.com/coolaj86/greenlock-koa.js.git"
|
"url": "git+https://git.coolaj86.com/coolaj86/greenlock-rill.js.git"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"acme",
|
"acme",
|
||||||
|
@ -19,7 +20,7 @@
|
||||||
"freessl",
|
"freessl",
|
||||||
"free ssl",
|
"free ssl",
|
||||||
"https",
|
"https",
|
||||||
"koa",
|
"rill",
|
||||||
"le",
|
"le",
|
||||||
"letsencrypt",
|
"letsencrypt",
|
||||||
"node",
|
"node",
|
||||||
|
|
Loading…
Reference in New Issue