2018-07-03 09:25:57 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////
|
|
|
|
// Greenlock Setup //
|
|
|
|
////////////////////////
|
|
|
|
|
|
|
|
//var Greenlock = require('greenlock-express');
|
|
|
|
var Greenlock = require('../');
|
|
|
|
var greenlock = Greenlock.create({
|
|
|
|
|
|
|
|
// Let's Encrypt v2 is ACME draft 11
|
|
|
|
// Note: If at first you don't succeed, stop and switch to staging
|
|
|
|
// https://acme-staging-v02.api.letsencrypt.org/directory
|
|
|
|
server: 'https://acme-v02.api.letsencrypt.org/directory'
|
|
|
|
, version: 'draft-11'
|
|
|
|
, configDir: '~/.config/acme/'
|
2018-08-18 10:08:50 +00:00
|
|
|
, app: require('./my-express-app.js')
|
2018-07-03 09:25:57 +00:00
|
|
|
|
|
|
|
// You MUST change these to a valid email and domains
|
|
|
|
, email: 'john.doe@example.com'
|
|
|
|
, approveDomains: [ 'example.com', 'www.example.com' ]
|
|
|
|
, agreeTos: true
|
|
|
|
|
|
|
|
// Get notified of important updates and help me make greenlock better
|
|
|
|
, communityMember: true
|
|
|
|
, telemetry: true
|
|
|
|
//, debug: true
|
|
|
|
});
|
|
|
|
|
2018-08-18 10:08:50 +00:00
|
|
|
var server = greenlock.listen(80, 443);
|
2018-07-03 09:25:57 +00:00
|
|
|
|
|
|
|
var WebSocket = require('ws');
|
|
|
|
var ws = new WebSocket.Server({ server: server });
|
|
|
|
ws.on('connection', function (ws, req) {
|
|
|
|
// inspect req.headers.authorization (or cookies) for session info
|
2018-07-03 09:30:15 +00:00
|
|
|
ws.send("[Secure Echo Server] Hello!\nAuth: '" + (req.headers.authorization || 'none') + "'\n"
|
|
|
|
+ "Cookie: '" + (req.headers.cookie || 'none') + "'\n");
|
|
|
|
ws.on('message', function (data) { ws.send(data); });
|
2018-07-03 09:25:57 +00:00
|
|
|
});
|