| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | # [Greenlock Express](https://git.rootprojects.org/root/greenlock-express.js) is Let's Encrypt for Node
 | 
					
						
							| 
									
										
										
										
											2019-09-04 00:15:02 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-15 22:19:58 -06:00
										 |  |  |  | 
					
						
							| 
									
										
										
										
											2018-05-12 07:46:56 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | | Built by [Root](https://therootcompany.com) for [Hub](https://rootprojects.org/hub/) | 
					
						
							| 
									
										
										
										
											2018-04-20 06:43:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | Free SSL, Automated HTTPS / HTTP2, served with Node via Express, Koa, hapi, etc. | 
					
						
							| 
									
										
										
										
											2018-05-10 00:53:45 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-05 03:09:42 -07:00
										 |  |  | ### Let's Encrypt for Node and Express (and Koa, hapi, rill, etc)
 | 
					
						
							| 
									
										
										
										
											2019-10-29 23:04:32 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-01 04:12:40 -06:00
										 |  |  | Greenlock Express is a **Web Server** with **Fully Automated HTTPS** and renewals. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-05 03:09:42 -07:00
										 |  |  | You define your app, and let Greenlock handle issuing and renewing Free SSL Certificates. | 
					
						
							| 
									
										
										
										
											2019-11-01 04:19:32 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-05 03:09:42 -07:00
										 |  |  | **Cloud-ready** with Node `cluster`. | 
					
						
							| 
									
										
										
										
											2019-11-01 04:19:32 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-05 03:30:07 -07:00
										 |  |  | # Serve your Sites with Free SSL
 | 
					
						
							| 
									
										
										
										
											2019-11-01 04:12:40 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-05 03:09:42 -07:00
										 |  |  | -   1. Create a Project with Greenlock Express | 
					
						
							|  |  |  | -   2. Initialize and Setup | 
					
						
							|  |  |  | -   3. Add Domains, and Hello, World! | 
					
						
							| 
									
										
										
										
											2019-11-01 15:14:07 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-05 03:09:42 -07:00
										 |  |  | ```bash | 
					
						
							|  |  |  | npm init | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ```bash | 
					
						
							| 
									
										
										
										
											2020-01-05 17:32:20 -07:00
										 |  |  | npm install --save greenlock-express@v4 | 
					
						
							| 
									
										
										
										
											2019-11-05 03:09:42 -07:00
										 |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ```bash | 
					
						
							| 
									
										
										
										
											2020-01-09 04:29:18 -07:00
										 |  |  | npx greenlock init --config-dir ./greenlock.d --maintainer-email 'jon@example.com' | 
					
						
							| 
									
										
										
										
											2019-11-05 03:09:42 -07:00
										 |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <details> | 
					
						
							|  |  |  | <summary>server.js</summary> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ```js | 
					
						
							|  |  |  | "use strict"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-09 04:29:18 -07:00
										 |  |  | var app = require("./app.js"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-05 03:09:42 -07:00
										 |  |  | require("greenlock-express") | 
					
						
							| 
									
										
										
										
											2019-11-18 00:53:26 -07:00
										 |  |  |     .init({ | 
					
						
							|  |  |  |         packageRoot: __dirname, | 
					
						
							| 
									
										
										
										
											2019-11-05 03:09:42 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-09 04:29:18 -07:00
										 |  |  |         // contact for security and critical bug notices | 
					
						
							|  |  |  |         configDir: "./greenlock.d", | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-18 00:53:26 -07:00
										 |  |  |         // whether or not to run at cloudscale | 
					
						
							|  |  |  |         cluster: false | 
					
						
							| 
									
										
										
										
											2019-11-01 15:14:07 -06:00
										 |  |  |     }) | 
					
						
							| 
									
										
										
										
											2020-01-09 04:29:18 -07:00
										 |  |  |     // Serves on 80 and 443 | 
					
						
							|  |  |  |     // Get's SSL certificates magically! | 
					
						
							|  |  |  |     .serve(app); | 
					
						
							| 
									
										
										
										
											2019-11-05 03:09:42 -07:00
										 |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | </details> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-05 04:01:58 -07:00
										 |  |  | <details> | 
					
						
							|  |  |  | <summary>app.js</summary> | 
					
						
							| 
									
										
										
										
											2019-11-05 03:09:42 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | ```js | 
					
						
							| 
									
										
										
										
											2019-11-18 00:53:26 -07:00
										 |  |  | "use strict"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-09 04:29:18 -07:00
										 |  |  | // Here's a vanilla HTTP app to start, | 
					
						
							|  |  |  | // but feel free to replace it with Express, Koa, etc | 
					
						
							| 
									
										
										
										
											2019-11-05 03:09:42 -07:00
										 |  |  | var app = function(req, res) { | 
					
						
							|  |  |  |     res.end("Hello, Encrypted World!"); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | module.exports = app; | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-05 04:01:58 -07:00
										 |  |  | </details> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-05 03:09:42 -07:00
										 |  |  | ```bash | 
					
						
							| 
									
										
										
										
											2019-11-18 00:53:26 -07:00
										 |  |  | npx greenlock add --subject example.com --altnames example.com | 
					
						
							| 
									
										
										
										
											2019-11-05 03:09:42 -07:00
										 |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-18 00:53:26 -07:00
										 |  |  | <details> | 
					
						
							| 
									
										
										
										
											2020-01-09 04:29:18 -07:00
										 |  |  | <summary>greenlock.d/config.json</summary> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <!-- TODO update manager to write array rather than object --> | 
					
						
							| 
									
										
										
										
											2019-11-18 00:53:26 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | ```json | 
					
						
							|  |  |  | { "sites": [{ "subject": "example.com", "altnames": ["example.com"] }] } | 
					
						
							| 
									
										
										
										
											2019-11-05 03:09:42 -07:00
										 |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-18 00:53:26 -07:00
										 |  |  | </details> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-05 03:09:42 -07:00
										 |  |  | ```bash | 
					
						
							| 
									
										
										
										
											2019-11-05 03:30:07 -07:00
										 |  |  | npm start -- --staging | 
					
						
							| 
									
										
										
										
											2016-08-12 03:02:33 -04:00
										 |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-05 04:17:31 -07:00
										 |  |  | ```txt | 
					
						
							|  |  |  | > my-project@1.0.0 start /srv/www/my-project
 | 
					
						
							|  |  |  | > node server.js
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Listening on 0.0.0.0:80 for ACME challenges and HTTPS redirects | 
					
						
							|  |  |  | Listening on 0.0.0.0:443 for secure traffic | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | # Let's Encrypt for...
 | 
					
						
							| 
									
										
										
										
											2018-11-15 00:22:16 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-01 15:14:07 -06:00
										 |  |  | -   IoT | 
					
						
							|  |  |  | -   Enterprise On-Prem | 
					
						
							|  |  |  | -   Local Development | 
					
						
							|  |  |  | -   Home Servers | 
					
						
							|  |  |  | -   Quitting Heroku | 
					
						
							| 
									
										
										
										
											2018-04-23 19:55:03 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | # Features
 | 
					
						
							| 
									
										
										
										
											2018-04-23 20:02:50 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-01 15:14:07 -06:00
										 |  |  | -   [x] Let's Encrypt v2 (November 2019) | 
					
						
							|  |  |  |     -   [x] ACME Protocol (RFC 8555) | 
					
						
							|  |  |  |     -   [x] HTTP Validation (HTTP-01) | 
					
						
							|  |  |  |     -   [x] DNS Validation (DNS-01) | 
					
						
							|  |  |  |     -   [ ] ALPN Validation (TLS-ALPN-01) | 
					
						
							|  |  |  |         -   Need ALPN validation? [contact us](mailto:greenlock-support@therootcompany.com) | 
					
						
							|  |  |  | -   [x] Automated HTTPS | 
					
						
							|  |  |  |     -   [x] Fully Automatic Renewals every 45 days | 
					
						
							|  |  |  |     -   [x] Free SSL | 
					
						
							|  |  |  |     -   [x] **Wildcard** SSL | 
					
						
							|  |  |  |     -   [x] **Localhost** certificates | 
					
						
							|  |  |  |     -   [x] HTTPS-enabled Secure **WebSockets** (`wss://`) | 
					
						
							|  |  |  | -   [x] Fully customizable | 
					
						
							|  |  |  |     -   [x] **Reasonable defaults** | 
					
						
							|  |  |  |     -   [x] Domain Management | 
					
						
							|  |  |  |     -   [x] Key and Certificate Management | 
					
						
							|  |  |  |     -   [x] ACME Challenge Plugins | 
					
						
							| 
									
										
										
										
											2018-04-23 20:02:50 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | # QuickStart Guide
 | 
					
						
							| 
									
										
										
										
											2018-04-23 20:02:50 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | Easy as 1, 2, 3... 4 | 
					
						
							| 
									
										
										
										
											2018-04-23 20:02:50 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-01 04:26:34 -06:00
										 |  |  | <details> | 
					
						
							| 
									
										
										
										
											2019-11-01 04:29:49 -06:00
										 |  |  | <summary>1. Create a node project</summary> | 
					
						
							| 
									
										
										
										
											2019-11-01 04:26:34 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | ## 1. Create a node project
 | 
					
						
							| 
									
										
										
										
											2018-04-20 07:14:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | Create an empty node project. | 
					
						
							| 
									
										
										
										
											2018-04-20 08:59:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | Be sure to fill out the package name, version, and an author email. | 
					
						
							| 
									
										
										
										
											2018-04-20 08:59:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | ```bash | 
					
						
							|  |  |  | mkdir ~/my-project | 
					
						
							|  |  |  | pushd ~/my-project | 
					
						
							|  |  |  | npm init | 
					
						
							| 
									
										
										
										
											2018-04-20 08:59:33 +00:00
										 |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-01 04:29:49 -06:00
										 |  |  | </details> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <details> | 
					
						
							|  |  |  | <summary>2. Create an http app (i.e. express)</summary> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | ## 2. Create an http app (i.e. express)
 | 
					
						
							| 
									
										
										
										
											2016-08-12 03:02:33 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-01 12:57:32 +00:00
										 |  |  | This example is shown with Express, but any node app will do. Greenlock | 
					
						
							| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | works with everything. | 
					
						
							|  |  |  | (or any node-style http app) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | `my-express-app.js`: | 
					
						
							| 
									
										
										
										
											2016-08-12 03:02:33 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | ```js | 
					
						
							| 
									
										
										
										
											2019-06-03 03:47:07 -06:00
										 |  |  | "use strict"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | // A plain, node-style app | 
					
						
							| 
									
										
										
										
											2016-08-15 21:15:16 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | function myPlainNodeHttpApp(req, res) { | 
					
						
							| 
									
										
										
										
											2019-11-01 15:14:07 -06:00
										 |  |  |     res.end("Hello, Encrypted World!"); | 
					
						
							| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2019-06-03 03:47:07 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | // Wrap that plain app in express, | 
					
						
							|  |  |  | // because that's what you're used to | 
					
						
							| 
									
										
										
										
											2016-08-12 03:02:33 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-03 03:47:07 -06:00
										 |  |  | var express = require("express"); | 
					
						
							| 
									
										
										
										
											2018-12-22 07:37:16 -07:00
										 |  |  | var app = express(); | 
					
						
							| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | app.get("/", myPlainNodeHttpApp); | 
					
						
							| 
									
										
										
										
											2018-05-10 00:53:45 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | // export the app normally | 
					
						
							|  |  |  | // do not .listen() | 
					
						
							| 
									
										
										
										
											2018-05-26 01:28:11 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-22 07:37:16 -07:00
										 |  |  | module.exports = app; | 
					
						
							| 
									
										
										
										
											2016-08-12 03:02:33 -04:00
										 |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-01 04:29:49 -06:00
										 |  |  | </details> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <details> | 
					
						
							|  |  |  | <summary>3. Serve with Greenlock Express</summary> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | ## 3. Serve with Greenlock Express
 | 
					
						
							| 
									
										
										
										
											2018-04-20 07:23:22 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | Greenlock Express is designed with these goals in mind: | 
					
						
							| 
									
										
										
										
											2016-08-12 03:02:33 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-01 15:14:07 -06:00
										 |  |  | -   Simplicity and ease-of-use | 
					
						
							|  |  |  | -   Performance and scalability | 
					
						
							|  |  |  | -   Configurability and control | 
					
						
							| 
									
										
										
										
											2018-05-19 17:54:08 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | You can start with **near-zero configuration** and | 
					
						
							|  |  |  | slowly add options for greater performance and customization | 
					
						
							|  |  |  | later, if you need them. | 
					
						
							| 
									
										
										
										
											2016-08-12 03:02:33 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | `server.js`: | 
					
						
							| 
									
										
										
										
											2018-05-19 17:54:08 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-28 03:52:38 -06:00
										 |  |  | ```js | 
					
						
							| 
									
										
										
										
											2019-11-05 04:01:58 -07:00
										 |  |  | "use strict"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-05 17:32:20 -07:00
										 |  |  | //var pkg = require("./package.json"); | 
					
						
							|  |  |  | var app = require("./app.js"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | require("greenlock-express") | 
					
						
							| 
									
										
										
										
											2020-01-05 17:32:20 -07:00
										 |  |  |     .init({ | 
					
						
							|  |  |  |         // name & version for ACME client user agent | 
					
						
							|  |  |  |         //packageAgent: pkg.name + "/" + pkg.version, | 
					
						
							| 
									
										
										
										
											2019-11-05 04:01:58 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-05 17:32:20 -07:00
										 |  |  |         // contact for security and critical bug notices | 
					
						
							|  |  |  |         maintainerEmail: pkg.author, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // where to find .greenlockrc and set default paths | 
					
						
							|  |  |  |         packageRoot: __dirname, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // where config and certificate stuff go | 
					
						
							|  |  |  |         configDir: "./greenlock.d", | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // whether or not to run at cloudscale | 
					
						
							|  |  |  |         cluster: false | 
					
						
							|  |  |  |     }) | 
					
						
							|  |  |  |     .serve(app); | 
					
						
							| 
									
										
										
										
											2018-05-19 17:54:08 -06:00
										 |  |  | ``` | 
					
						
							| 
									
										
										
										
											2016-08-12 03:02:33 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | And start your server: | 
					
						
							| 
									
										
										
										
											2018-04-20 08:59:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | ```bash | 
					
						
							|  |  |  | # Allow non-root node to use ports 80 (HTTP) and 443 (HTTPS)
 | 
					
						
							|  |  |  | sudo setcap 'cap_net_bind_service=+ep' $(which node) | 
					
						
							| 
									
										
										
										
											2018-04-20 08:59:33 +00:00
										 |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | ```bash | 
					
						
							|  |  |  | # `npm start` will call `node ./server.js` by default
 | 
					
						
							|  |  |  | npm start | 
					
						
							| 
									
										
										
										
											2018-04-20 08:59:33 +00:00
										 |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-05 04:01:58 -07:00
										 |  |  | ```bash | 
					
						
							|  |  |  | # use --staging to use the development API until you're ready to get real certificates
 | 
					
						
							|  |  |  | npm start -- --staging | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | ```txt | 
					
						
							| 
									
										
										
										
											2020-01-05 17:32:20 -07:00
										 |  |  | Greenlock v4.0.0 | 
					
						
							|  |  |  | Greenlock Config Dir/File: ./greenlock.d/config.json | 
					
						
							| 
									
										
										
										
											2019-06-03 03:47:07 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | Listening on 0.0.0.0:80 for ACME challenges and HTTPS redirects | 
					
						
							|  |  |  | Listening on 0.0.0.0:443 for secure traffic | 
					
						
							|  |  |  | ``` | 
					
						
							| 
									
										
										
										
											2019-06-03 03:47:07 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-01 04:29:49 -06:00
										 |  |  | </details> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <details> | 
					
						
							|  |  |  | <summary>4. Manage SSL Certificates and Domains</summary> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | ## 4. Manage domains
 | 
					
						
							| 
									
										
										
										
											2018-08-17 19:58:50 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-01 04:12:40 -06:00
										 |  |  | The management API is built to work with Databases, S3, etc. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-05 04:01:58 -07:00
										 |  |  | By default, it's just a simple config file and directory. | 
					
						
							| 
									
										
										
										
											2019-11-01 04:12:40 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-05 04:01:58 -07:00
										 |  |  | ```bash | 
					
						
							|  |  |  | # see which manager and what options are in use
 | 
					
						
							|  |  |  | cat .greenlockrc | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <details> | 
					
						
							|  |  |  | <summary>Example Output</summary> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ```json | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2020-01-05 17:32:20 -07:00
										 |  |  |     "manager": { | 
					
						
							|  |  |  |         "module": "@greenlock/manager" | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     "configDir": "./greenlock.d" | 
					
						
							| 
									
										
										
										
											2019-11-05 04:01:58 -07:00
										 |  |  | } | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | </details> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ```bash | 
					
						
							|  |  |  | # show the global defaults
 | 
					
						
							|  |  |  | npx greenlock defaults | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ```js | 
					
						
							|  |  |  | var defaults = await greenlock.defaults(); | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <details> | 
					
						
							|  |  |  | <summary>Example Output</summary> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ```json | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     "store": { | 
					
						
							|  |  |  |         "module": "greenlock-store-fs", | 
					
						
							|  |  |  |         "basePath": "./greenlock.d" | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     "challenges": { | 
					
						
							|  |  |  |         "http-01": { | 
					
						
							|  |  |  |             "module": "acme-http-01-standalone" | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     "renewOffset": "-45d", | 
					
						
							|  |  |  |     "renewStagger": "3d", | 
					
						
							|  |  |  |     "accountKeyType": "EC-P256", | 
					
						
							|  |  |  |     "serverKeyType": "RSA-2048", | 
					
						
							|  |  |  |     "subscriberEmail": "jon@example.com", | 
					
						
							|  |  |  |     "agreeToTerms": true | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | </details> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ```bash | 
					
						
							|  |  |  | # show per-site configs
 | 
					
						
							|  |  |  | npx greenlock config --subject example.com | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ```js | 
					
						
							|  |  |  | greenlock.sites.get({ subject: "example.com" }); | 
					
						
							|  |  |  | ``` | 
					
						
							| 
									
										
										
										
											2019-11-01 04:12:40 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-05 04:01:58 -07:00
										 |  |  | <details> | 
					
						
							|  |  |  | <summary>Example Output</summary> | 
					
						
							| 
									
										
										
										
											2019-11-01 04:12:40 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | ```json | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-11-05 04:01:58 -07:00
										 |  |  |     "subject": "example.com", | 
					
						
							|  |  |  |     "altnames": ["example.com"], | 
					
						
							|  |  |  |     "renewAt": 1576638107754, | 
					
						
							|  |  |  |     "defaults": { | 
					
						
							|  |  |  |         "store": { | 
					
						
							|  |  |  |             "module": "greenlock-store-fs", | 
					
						
							|  |  |  |             "basePath": "./greenlock.d" | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         "challenges": { | 
					
						
							|  |  |  |             "http-01": { | 
					
						
							|  |  |  |                 "module": "acme-http-01-standalone" | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2019-11-01 15:14:07 -06:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-11-01 04:12:40 -06:00
										 |  |  | } | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-05 04:01:58 -07:00
										 |  |  | </details> | 
					
						
							| 
									
										
										
										
											2019-11-01 04:12:40 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-05 04:01:58 -07:00
										 |  |  | Management can be done via the **CLI** or the JavaScript [**API**](https://git.rootprojects.org/root/greenlock.js). | 
					
						
							| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | Since this is the QuickStart, we'll demo the **CLI**: | 
					
						
							| 
									
										
										
										
											2016-08-12 03:02:33 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | You need to create a Let's Encrypt _subscriber account_, which can be done globally, or per-site. | 
					
						
							|  |  |  | All individuals, and most businesses, should set this globally: | 
					
						
							| 
									
										
										
										
											2018-08-17 20:43:32 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | ```bash | 
					
						
							|  |  |  | # Set a global subscriber account
 | 
					
						
							| 
									
										
										
										
											2019-11-05 04:01:58 -07:00
										 |  |  | npx greenlock defaults --subscriber-email 'mycompany@example.com' --agree-to-terms true | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ```js | 
					
						
							|  |  |  | greenlock.manager.defaults({ | 
					
						
							|  |  |  |     subscriberEmail: "mycompany@example.com", | 
					
						
							|  |  |  |     agreeToTerms: true | 
					
						
							|  |  |  | }); | 
					
						
							| 
									
										
										
										
											2018-08-17 20:43:32 -06:00
										 |  |  | ``` | 
					
						
							| 
									
										
										
										
											2018-04-20 07:09:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | <!-- todo print where the key was saved --> | 
					
						
							| 
									
										
										
										
											2018-12-22 07:37:16 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | A Let's Encrypt SSL certificate has a "Subject" (Primary Domain) and up to 100 "Alternative Names" | 
					
						
							|  |  |  | (of which the first _must_ be the subject). | 
					
						
							| 
									
										
										
										
											2016-08-17 09:11:10 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | ```bash | 
					
						
							|  |  |  | # Add a certificate with specific domains
 | 
					
						
							|  |  |  | npx greenlock add --subject example.com --altnames example.com,www.example.com | 
					
						
							|  |  |  | ``` | 
					
						
							| 
									
										
										
										
											2016-08-17 09:11:10 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-05 04:01:58 -07:00
										 |  |  | ```js | 
					
						
							|  |  |  | greenlock.sites.add({ | 
					
						
							|  |  |  |     subject: "example.com", | 
					
						
							|  |  |  |     altnames: ["example.com"] | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | <!-- todo print where the cert was saved --> | 
					
						
							| 
									
										
										
										
											2018-05-11 20:29:21 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | Note: **Localhost**, **Wildcard**, and Certificates for Private Networks require | 
					
						
							|  |  |  | [**DNS validation**](https://git.rootprojects.org/root/greenlock-exp). | 
					
						
							| 
									
										
										
										
											2016-08-17 09:25:07 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-01 15:14:07 -06:00
										 |  |  | -   DNS Validation | 
					
						
							|  |  |  |     -   [**Wildcards**](https://git.rootprojects.org/root/greenlock-express.js/src/branch/master/examples/wildcards/) (coming soon) | 
					
						
							|  |  |  |     -   [**Localhost**](https://git.rootprojects.org/root/greenlock-express.js/src/branch/master/examples/localhost/) (coming soon) | 
					
						
							|  |  |  |     -   [**CI/CD**](https://git.rootprojects.org/root/greenlock-express.js/src/branch/master/examples/ci-cd/) (coming soon) | 
					
						
							| 
									
										
										
										
											2016-08-17 09:25:07 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-01 04:26:34 -06:00
										 |  |  | </details> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Plenty of Examples
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-01 15:14:07 -06:00
										 |  |  | -   [greenlock-express.js/examples/](https://git.rootprojects.org/root/greenlock-express.js/src/branch/master/examples) | 
					
						
							|  |  |  |     -   [Express](https://git.rootprojects.org/root/greenlock-express.js/src/branch/master/examples/express/) | 
					
						
							|  |  |  |     -   [Node's **http2**](https://git.rootprojects.org/root/greenlock-express.js/src/branch/master/examples/http2/) | 
					
						
							|  |  |  |     -   [Node's https](https://git.rootprojects.org/root/greenlock-express.js/src/branch/master/examples/https/) | 
					
						
							|  |  |  |     -   [**WebSockets**](https://git.rootprojects.org/root/greenlock-express.js/src/branch/master/examples/websockets/) | 
					
						
							| 
									
										
										
										
											2019-11-05 03:09:42 -07:00
										 |  |  |     -   [Socket.IO](https://git.rootprojects.org/root/greenlock-express.js/src/branch/master/examples/socket.io/) | 
					
						
							| 
									
										
										
										
											2019-11-01 15:14:07 -06:00
										 |  |  |     -   [Cluster](https://git.rootprojects.org/root/greenlock-express.js/src/branch/master/examples/cluster/) | 
					
						
							|  |  |  |     -   [**Wildcards**](https://git.rootprojects.org/root/greenlock-express.js/src/branch/master/examples/wildcards/) (coming soon) | 
					
						
							|  |  |  |     -   [**Localhost**](https://git.rootprojects.org/root/greenlock-express.js/src/branch/master/examples/localhost/) (coming soon) | 
					
						
							|  |  |  |     -   [**CI/CD**](https://git.rootprojects.org/root/greenlock-express.js/src/branch/master/examples/ci-cd/) (coming soon) | 
					
						
							|  |  |  |     -   [HTTP Proxy](https://git.rootprojects.org/root/greenlock-express.js/src/branch/master/examples/http-proxy/) | 
					
						
							| 
									
										
										
										
											2019-11-01 04:26:34 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | # Easy to Customize
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <!-- greenlock-manager-test => greenlock-manager-custom --> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <!--
 | 
					
						
							|  |  |  | - [greenlock.js/examples/](https://git.rootprojects.org/root/greenlock.js/src/branch/master/examples) | 
					
						
							|  |  |  | --> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-01 15:14:07 -06:00
										 |  |  | -   [Custom Domain Management](https://git.rootprojects.org/root/greenlock-manager-test.js) | 
					
						
							| 
									
										
										
										
											2019-11-05 04:01:58 -07:00
										 |  |  |     -   `npx greenlock init --manager ./path-or-npm-name.js --manager-FOO 'set option FOO'` | 
					
						
							| 
									
										
										
										
											2019-11-01 15:14:07 -06:00
										 |  |  | -   [Custom Key & Cert Storage](https://git.rootprojects.org/root/greenlock-store-test.js) | 
					
						
							| 
									
										
										
										
											2019-11-05 04:01:58 -07:00
										 |  |  |     -   `npx greenlock defaults --store greenlock-store-fs --store-base-path ./greenlock.d` | 
					
						
							| 
									
										
										
										
											2019-11-01 15:14:07 -06:00
										 |  |  | -   [Custom ACME HTTP-01 Challenges](https://git.rootprojects.org/root/acme-http-01-test.js) | 
					
						
							| 
									
										
										
										
											2019-11-05 04:01:58 -07:00
										 |  |  |     -   `npx greenlock defaults --challenge-http-01 ./you-http-01.js` | 
					
						
							|  |  |  |     -   `npx greenlock update --subject example.com --challenge-http-01 acme-http-01-standalone` | 
					
						
							| 
									
										
										
										
											2019-11-01 15:14:07 -06:00
										 |  |  | -   [Custom ACME DNS-01 Challenges](https://git.rootprojects.org/root/acme-dns-01-test.js) | 
					
						
							| 
									
										
										
										
											2019-11-05 04:01:58 -07:00
										 |  |  |     -   `npx greenlock defaults --challenge-dns-01 acme-dns-01-ovh --challenge-dns-01-token xxxx` | 
					
						
							| 
									
										
										
										
											2019-11-05 04:20:17 -07:00
										 |  |  |     -   `npx greenlock update --subject example.com --challenge-dns-01 ./your-dns-01.js` | 
					
						
							| 
									
										
										
										
											2019-11-01 04:26:34 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | # Ready-made Integrations
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Greenlock Express integrates between Let's Encrypt's ACME Challenges and many popular services. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | | Type        | Service                                                                             | Plugin                   | | 
					
						
							|  |  |  | | ----------- | ----------------------------------------------------------------------------------- | ------------------------ | | 
					
						
							|  |  |  | | dns-01      | CloudFlare                                                                          | acme-dns-01-cloudflare   | | 
					
						
							|  |  |  | | dns-01      | [Digital Ocean](https://git.rootprojects.org/root/acme-dns-01-digitalocean.js)      | acme-dns-01-digitalocean | | 
					
						
							|  |  |  | | dns-01      | [DNSimple](https://git.rootprojects.org/root/acme-dns-01-dnsimple.js)               | acme-dns-01-dnsimple     | | 
					
						
							|  |  |  | | dns-01      | [DuckDNS](https://git.rootprojects.org/root/acme-dns-01-duckdns.js)                 | acme-dns-01-duckdns      | | 
					
						
							|  |  |  | | http-01     | File System / [Web Root](https://git.rootprojects.org/root/acme-http-01-webroot.js) | acme-http-01-webroot     | | 
					
						
							|  |  |  | | dns-01      | [GoDaddy](https://git.rootprojects.org/root/acme-dns-01-godaddy.js)                 | acme-dns-01-godaddy      | | 
					
						
							|  |  |  | | dns-01      | [Gandi](https://git.rootprojects.org/root/acme-dns-01-gandi.js)                     | acme-dns-01-gandi        | | 
					
						
							|  |  |  | | dns-01      | [NameCheap](https://git.rootprojects.org/root/acme-dns-01-namecheap.js)             | acme-dns-01-namecheap    | | 
					
						
							|  |  |  | | dns-01      | [Name.com](https://git.rootprojects.org/root/acme-dns-01-namedotcom.js)         | acme-dns-01-namedotcom   | | 
					
						
							|  |  |  | | dns-01      | Route53 (AWS)                                                                       | acme-dns-01-route53      | | 
					
						
							|  |  |  | | http-01     | S3 (AWS, Digital Ocean, Scaleway)                                                   | acme-http-01-s3          | | 
					
						
							|  |  |  | | dns-01      | [Vultr](https://git.rootprojects.org/root/acme-dns-01-vultr.js)                     | acme-dns-01-vultr        | | 
					
						
							|  |  |  | | dns-01      | [Build your own](https://git.rootprojects.org/root/acme-dns-01-test.js)             | acme-dns-01-test         | | 
					
						
							|  |  |  | | http-01     | [Build your own](https://git.rootprojects.org/root/acme-http-01-test.js)            | acme-http-01-test        | | 
					
						
							|  |  |  | | tls-alpn-01 | [Contact us](mailto:support@therootcompany.com)                                     | -                        | | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-05 04:01:58 -07:00
										 |  |  | Example Usage: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ```bash | 
					
						
							|  |  |  | npx greenlock defaults --challenge-dns-01 acme-dns-01-ovh --challenge-dns-01-token xxxx | 
					
						
							|  |  |  | npx greenlock defaults --challenge-http-01 acme-http-01-s3 --challenge-http-01-bucket my-bucket | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-01 04:26:34 -06:00
										 |  |  | Search `acme-http-01-` or `acme-dns-01-` on npm to find more. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | # Full Documentation
 | 
					
						
							| 
									
										
										
										
											2016-08-12 03:56:19 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | <!--
 | 
					
						
							|  |  |  | - Greenlock CLI | 
					
						
							|  |  |  | - Greenlock JavaScript API | 
					
						
							|  |  |  | --> | 
					
						
							| 
									
										
										
										
											2016-08-15 21:15:16 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | Most of the documentation is done by use-case examples, as shown up at the top of the README. | 
					
						
							| 
									
										
										
										
											2016-08-15 19:12:39 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | We're working on more comprehensive documentation for this newly released version. | 
					
						
							|  |  |  | **Please open an issue** with questions in the meantime. | 
					
						
							| 
									
										
										
										
											2016-08-15 19:12:39 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | # Commercial Support
 | 
					
						
							| 
									
										
										
										
											2016-08-12 03:56:19 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | Do you need... | 
					
						
							| 
									
										
										
										
											2016-08-12 03:56:19 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-01 15:14:07 -06:00
										 |  |  | -   training? | 
					
						
							|  |  |  | -   specific features? | 
					
						
							|  |  |  | -   different integrations? | 
					
						
							|  |  |  | -   bugfixes, on _your_ timeline? | 
					
						
							|  |  |  | -   custom code, built by experts? | 
					
						
							|  |  |  | -   commercial support and licensing? | 
					
						
							| 
									
										
										
										
											2018-05-03 00:55:35 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | You're welcome to [contact us](mailto:aj@therootcompany.com) in regards to IoT, On-Prem, | 
					
						
							|  |  |  | Enterprise, and Internal installations, integrations, and deployments. | 
					
						
							| 
									
										
										
										
											2018-05-03 00:55:35 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | We have both commercial support and commercial licensing available. | 
					
						
							| 
									
										
										
										
											2018-05-31 21:14:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-28 03:43:53 -06:00
										 |  |  | We also offer consulting for all-things-ACME and Let's Encrypt. | 
					
						
							| 
									
										
										
										
											2018-11-15 00:22:16 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-15 22:19:58 -06:00
										 |  |  | # Legal & Rules of the Road
 | 
					
						
							| 
									
										
										
										
											2018-12-17 01:04:39 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-15 22:19:58 -06:00
										 |  |  | Greenlock™ is a [trademark](https://rootprojects.org/legal/#trademark) of AJ ONeal | 
					
						
							| 
									
										
										
										
											2018-11-15 00:22:16 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-15 22:19:58 -06:00
										 |  |  | The rule of thumb is "attribute, but don't confuse". For example: | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-15 22:39:35 -06:00
										 |  |  | > Built with [Greenlock Express](https://git.rootprojects.org/root/greenlock.js) (a [Root](https://rootprojects.org) project).
 | 
					
						
							| 
									
										
										
										
											2019-05-15 22:19:58 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | Please [contact us](mailto:aj@therootcompany.com) if you have any questions in regards to our trademark, | 
					
						
							|  |  |  | attribution, and/or visible source policies. We want to build great software and a great community. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [Greenlock™](https://git.rootprojects.org/root/greenlock.js) | | 
					
						
							| 
									
										
										
										
											2018-12-17 01:04:39 -07:00
										 |  |  | MPL-2.0 | | 
					
						
							|  |  |  | [Terms of Use](https://therootcompany.com/legal/#terms) | | 
					
						
							|  |  |  | [Privacy Policy](https://therootcompany.com/legal/#privacy) |