more attention on the simple example
This commit is contained in:
parent
df1259cd9d
commit
894a01fa4e
40
README.md
40
README.md
|
@ -6,22 +6,42 @@
|
||||||
|
|
||||||
Free SSL, Automated HTTPS / HTTP2, served with Node via Express, Koa, hapi, etc.
|
Free SSL, Automated HTTPS / HTTP2, served with Node via Express, Koa, hapi, etc.
|
||||||
|
|
||||||
|
### Let's Encrypt for Node, Express, etc
|
||||||
|
|
||||||
```js
|
```js
|
||||||
require("greenlock-express")
|
require("greenlock-express")
|
||||||
.init(getConfig)
|
.init(function getConfig() {
|
||||||
.serve(worker);
|
return { package: require("./package.json") };
|
||||||
|
})
|
||||||
|
.serve(httpsWorker);
|
||||||
|
|
||||||
function getConfig() {
|
function httpsWorker(server) {
|
||||||
return {
|
|
||||||
package: require("./package.json")
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function worker(server) {
|
|
||||||
server.serveApp(function(req, res) {
|
|
||||||
// Works with any Node app (Express, etc)
|
// Works with any Node app (Express, etc)
|
||||||
|
var app = require("./my-express-app.js");
|
||||||
|
|
||||||
|
// See, all normal stuff here
|
||||||
|
app.get("/hello", function(req, res) {
|
||||||
res.end("Hello, Encrypted World!");
|
res.end("Hello, Encrypted World!");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Serves on 80 and 443
|
||||||
|
// Get's SSL certificates magically!
|
||||||
|
server.serveApp(app);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Manage via API or the config file:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"subscriberEmail": "letsencrypt-test@therootcompany.com",
|
||||||
|
"agreeToTerms": true,
|
||||||
|
"sites": {
|
||||||
|
"example.com": {
|
||||||
|
"subject": "example.com",
|
||||||
|
"altnames": ["example.com", "www.example.com"]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue