http + https =
const Koa = require('koa');
const app = new Koa();
http.createServer(app.callback()).listen(80);
const options = {
key: fs.readFileSync('./ssl/private.pem', 'utf8'),
cert: fs.readFileSync('./ssl/20180303.crt', 'utf8')
};
https.createServer(options, app.callback()).listen(443);
http + ws =
const Koa = require('koa');
const websockify = require('koa-websocket');
const app = websockify(new Koa());
app.listen(80);
https + wss = ?
Any solution you might found?
@avihaymenahem No solution now, need somebody to develop a package to support it (https + wss).
In anyway, you can perfectly stick with HTTP on the Koa side and use a reverse-proxy (nginx, httpd) to enable HTTPS — I think most people use Koa this way (at least I use Koa this way).
@motet-a, Not use nginx, only a single ECS.
you can do it this way:
const server = new Koa();
// ... middlewares and routes
const options = {
// Local certificates, if you don;t have them generate from mkcert or letsEncrypt
key: fs.readFileSync("localhost-key.pem"),
cert: fs.readFileSync("localhost.pem")
};
https.createServer(options, server.callback()).listen(port);
Most helpful comment
In anyway, you can perfectly stick with HTTP on the Koa side and use a reverse-proxy (nginx, httpd) to enable HTTPS — I think most people use Koa this way (at least I use Koa this way).