Skip to content
simple and free http2 with express | 简单免费给express升级http2
JavaScript
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs
example
src
.gitignore
README.md
package.json
yarn.lock

README.md

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"
You can’t perform that action at this time.