certbot-express

1.0.2 • Public • Published

certbot-express

simple and free http2 with express | 简单免费给express升级http2

prepare | 准备

if you are not using certbot, skip this | 如果你不使用certbot,跳过此步骤

certbot

install certbot

generate certification | 生成证书

point your domain to your server | 将域名指向要部署的服务器

certbot certonly

see full conversation here | 查看命令对话详情

install | 安装

npm install certbot-express

usage | 使用

const express = require('express')
const { redirect, http2 } = require('certbot-express')

const app = express()
const certDir = '/etc/letsencrypt/live/test.i18ntech.com/' // you can get certDir from env
const dev = process.env.NODE_ENV !== 'production'

app.use(redirect)
app.use('/', (req, res) => {
  res.send('http2!')
})

http2({
  dev,  //if dev is true only http is served, all about http2 are skipped
  certDir,
  app,
}).listen().then(() => {
  console.log('server started')
}).catch((e) => {
  console.log(e)
})

or | 或者

http2({
  keyPath:'/etc/letsencrypt/live/test.i18ntech.com/privkey.pem',
  certPath:'/etc/letsencrypt/live/test.i18ntech.com/fullchain.pem'
  app,
})

renew certification | 更新证书

it might be something like this, you can add it to your cron job

certbot renew --pre-hook "forever stop app.js" --post-hook "forever start app.js"

Readme

Keywords

none

Package Sidebar

Install

npm i certbot-express

Weekly Downloads

5

Version

1.0.2

License

ISC

Unpacked Size

79.5 kB

Total Files

11

Last publish

Collaborators

  • lyjhit