• Stars
    star
    126
  • Rank 284,543 (Top 6 %)
  • Language
    Ruby
  • License
    MIT License
  • Created over 7 years ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The Let's Encrypt certificate manager for rails

LetsEncrypt Gem Version Build Status Coverage Status Code Climate

Provide manageable Let's Encrypt Certificate for Rails.

Requirement

  • Rails 5+
  • Ruby 2.5+

Installation

Puts this in your Gemfile:

gem 'rails-letsencrypt'

Run install migrations

rails generate lets_encrypt:install
rake db:migrate

Setup private key for Let's Encrypt API, and create an account at letsencrypt.org associated with that key

rails generate lets_encrypt:register

Add acme-challenge mounts in config/routes.rb

mount LetsEncrypt::Engine => '/.well-known'

Configuration

Add a file to config/initializers/letsencrypt.rb and put below config you need.

LetsEncrypt.config do |config|
  # Using Let's Encrypt staging server or not
  # Default only `Rails.env.production? == true` will use Let's Encrypt production server.
  config.use_staging = true

  # Set the private key path
  # Default is locate at config/letsencrypt.key
  config.private_key_path = Rails.root.join('config', 'letsencrypt.key')

  # Use environment variable to set private key
  # If enable, the API Client will use `LETSENCRYPT_PRIVATE_KEY` as private key
  # Default is false
  config.use_env_key = false

  # Should sync certificate into redis
  # When using ngx_mruby to dynamic load certificate, this will be helpful
  # Default is false
  config.save_to_redis = false

  # The redis server url
  # Default is nil
  config.redis_url = 'redis://localhost:6379/1'

  # Enable it if you want to customize the model
  # Default is LetsEncrypt::Certificate
  #config.certificate_model = 'MyCertificate'
end

Usage

The SSL certificate setup depends on the web server, this gem can work with ngx_mruby or kong.

Certificate Model

Create

Add a new domain into the database.

cert = LetsEncrypt::Certificate.create(domain: 'example.com')
cert.get # alias  `verify && issue`

Verify

Makes a request to Let's Encrypt and verify domain

cert = LetsEncrypt::Certificate.find_by(domain: 'example.com')
cert.verify

Issue

Ask Let's Encrypt to issue a new certificate.

cert = LetsEncrypt::Certificate.find_by(domain: 'example.com')
cert.issue

Renew

cert = LetsEncrypt::Certificate.find_by(domain: 'example.com')
cert.renew

Status

Check a certificate is verified and issued.

cert = LetsEncrypt::Certificate.find_by(domain: 'example.com')
cert.active? # => true

Check a certificate is expired.

cert = LetsEncrypt::Certificate.find_by(domain: 'example.com')
cert.expired? # => false

Tasks

To renew a certificate, you can run renew task to renew coming expires certificates.

rake letsencrypt:renew

Jobs

If you are using Sidekiq or others, you can enqueue renew task daily.

LetsEncrypt::RenewCertificatesJob.perform_later

ngx_mruby

The setup is following this Article

Add config/initializers/letsencrypt.rb to add config to sync certificate.

LetsEncrypt.config do |config|
  config.redis_url = 'redis://localhost:6379/1'
  config.save_to_redis = true
end

Connect Redis when Nginx worker start

http {
  # ...
  mruby_init_worker_code '
    userdata = Userdata.new
    userdata.redis = Redis.new "127.0.0.1", 6379
    # If your redis database is not 0, please select a correct one
    userdata.redis.select 1
  ';
}

Setup SSL using mruby

server {
  listen 443 ssl;
  server_name _;

  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  ssl_ciphers HIGH:!aNULL:!MD5;
  ssl_certificate certs/dummy.crt;
  ssl_certificate_key certs/dummy.key;

  mruby_ssl_handshake_handler_code '
    ssl = Nginx::SSL.new
    domain = ssl.servername

    redis = Userdata.new.redis
    unless redis["#{domain}.crt"].nil? and redis["#{domain}.key"].nil?
      ssl.certificate_data = redis["#{domain}.crt"]
      ssl.certificate_key_data = redis["#{domain}.key"]
    end
  ';
}

Kong

Coming soon.

License

The gem is available as open source under the terms of the MIT License.

More Repositories

1

boxing

The zero-configuration Dockerfile generator for Ruby.
Ruby
61
star
2

mwc

The tool to compile mruby on WebAssembly
Ruby
18
star
3

ruby-gitlab-ci

The GitLab CI templates for Ruby project
12
star
4

go-plurk-robot

็™ปๅ…ฅๅœ‹่ป Online ็‚บไบ†ๅฎ‰ๆ’ซๅฏ‚ๅฏž็š„็ถฒๅ‹๏ผˆๆ‰ๆฒ’ๆœ‰๏ผ‰ๆ‰€่ฃฝไฝœ็š„ๆฉŸๅ™จไบบ
Go
11
star
5

heroku-buildpacks-php-with-phalcon

Heroku Buikdpack PHP with PhalconPHP and Composer
Shell
11
star
6

mruby-go

The pure go mruby virtual machine implementation.
Go
11
star
7

doll

The Chatbot Framework written in Ruby
Ruby
10
star
8

mruby.wasm

mruby WebAssembly using WebIDL
HTML
9
star
9

openbox

The zero-configuration Ruby container entry-point.
Ruby
9
star
10

terraform-provider-lambdalabs

The Lambdalabs provider for Terraform
Go
8
star
11

liveness

The Rack middleware to provide health check endpoints.
Ruby
8
star
12

replicate-pastel-mix

The pastel-mix model implementation on replicate
Python
8
star
13

laravel-guestbook-example

A simple guestbook create via Laravel Framework
PHP
8
star
14

mcoin

The cryptocurrency market monitor tool
Ruby
7
star
15

FiveFood

ไบ”้ฃŸ๏ผŒๆฏๅ€‹ไธŠ็ญๆ—ๅฟ…ๅ‚™็š„ๅˆ้คๆฑบ็ญ–็ณป็ตฑใ€‚
Ruby
7
star
16

hiro

The game framework based on mruby.
C
6
star
17

middleman-webpacked

Ruby
6
star
18

magica

A tool to build C++ project
Ruby
5
star
19

tide.ex

Communicate with Ruby via Erlport
Elixir
5
star
20

terraform-proxmox-kubernetes

The terraform module for create Kuberentes cluster on ProxmoxVE
HCL
5
star
21

30minGuestBook

PHP
5
star
22

administrate-notus_theme

The Administrate Notus Theme designed by Creative Tim
CSS
5
star
23

mitake

The ruby gem for Mitake SMS
Ruby
4
star
24

blog-ai.aotoki.me

The RAG API for blog.aotoki.me
TypeScript
4
star
25

hanami-lambda

Hanami Lambda is a gem that provides a way to run hanami application on AWS Lambda.
Ruby
4
star
26

gitlab-sonar-scanner

The sonar runner for gitlab-ci
Shell
4
star
27

pagoda-wp-zh_TW

WordPress zh_TW on PagodaBox
PHP
4
star
28

ai-gacha

Generate a mobile game-like card from AI
TypeScript
4
star
29

GlobalGameJam2023

Global Game Jam 2023 @ Taipei, Taiwan
TypeScript
4
star
30

202102-tdd-refactor-budget

The budget query practice of TDD & Refactor class
Ruby
3
star
31

5compiler

The compiler example written in Ruby
Ruby
3
star
32

book-craft-your-mruby-virtual-machine

The sample code of my book - craft-your-mruby-virtual-machine
C
3
star
33

warden-line

The warden strategies for LINE ID Token
Ruby
3
star
34

mask-map

2020 ๅนดๆœ€ๆต่กŒ็š„ๅฃ็ฝฉๅœฐๅœ–
Vue
3
star
35

lita-gitlab-ci

Lita Gitlab handler for send message about build status.
Ruby
3
star
36

packer-rails

Using Packer.io to builds Ruby on Rails image.
Shell
3
star
37

flowhook

Convert flowdock straming into webhook
Ruby
3
star
38

nginx-pagespeed

A docker image include nginx with pagespeed.
Shell
2
star
39

elct9620.github.com

My personal website.
HTML
2
star
40

MRubyShader

Using OpenFrameworks and mruby to build a simple shader playground.
C++
2
star
41

iv-plurk

The Plurk API client
Ruby
2
star
42

newebpay-ruby

The offsite payments implement for Newebpay
Ruby
2
star
43

MCUCourseAPI

A Ming Chuan University Course API service, using phalcon on heroku.
PHP
2
star
44

mcu-course-query-demo

A simple mcu course query demo.
JavaScript
2
star
45

plurk-salary

JavaScript
2
star
46

wvs

The "Walrus vs Slime" rewritten in DDD style
Go
2
star
47

Aotoki-Backbone.js

My Backbone.js Practice
2
star
48

mruby-shader-generator

The Ruby DSL GLSL shader code
Ruby
2
star
49

.cat

The loading cat generator
Ruby
2
star
50

cybersource

The ruby gem for Visa CyberSource API
Ruby
2
star
51

dcha

An blockchain test live in LAN using Multicast
Ruby
1
star
52

hahamut

The Bahamut Forum's chatbot ruby client implement
Ruby
1
star
53

hubot-plurk

HuBot ็š„ Plurk Adapter
1
star
54

ddd-in-unity3d-demo

A toy project to verify DDD can works in Unity3D
ShaderLab
1
star
55

try_git

1
star
56

coscup-2020-cdktf

Demo project for COSCUP 2020 LT
TypeScript
1
star
57

ar-bottle-royale

The Global Game Jam 2021
Ruby
1
star
58

turn-based-game-model-prototype

The turn-based game model prototype for @BasalticStudio NewEra
Ruby
1
star
59

RichBike

The web game prototype built in 5xRuby's Vue x uBike workshop
Ruby
1
star
60

do-kubernetes-challenge-2021

The DigitalOcean Kubernetes Challenge at 2021
Ruby
1
star
61

go-steam

Steam Web API implements in Go
Go
1
star
62

elct9620

My Profile README
1
star
63

open-story

The experimental open world story bot
Ruby
1
star
64

FlashSocketIO

FlashSocketIO implement, via AS3Websocket
ActionScript
1
star
65

gh-category

Firefox OS App Days @ Taiwan Project - Github Category
JavaScript
1
star
66

coscup-chat

A simple socket.io/express chat create at COSCUP 2012.
JavaScript
1
star
67

ac-nh-turnip-prices

Ruby
1
star
68

go-chatter

A practice using golang write a simple chatroom.
CSS
1
star
69

build-game-with-react-prototype

Inspired by https://steina.vercel.app
JavaScript
1
star
70

granblue.api

The API Endpoint for Granblue Fantasy Database
Go
1
star
71

fireplurk

A simple plurk public timeline webapp.
JavaScript
1
star
72

cucumber-playwright-example

Use cucumber and playwright together for E2E testing
TypeScript
1
star
73

elct9620-vim

My personal vimrc version.
Vim Script
1
star
74

phpconf2014-sample

My PHPConf 2014 (Taiwan) talk's sample code.
PHP
1
star
75

elixir-mud

Elixir TCP Server practice
Elixir
1
star
76

MCUCourseCLI

Ming Chuan University Course command line tools for developer.
PHP
1
star
77

pio-mrubyc

Provide mruby/c support for PlatformIO
Python
1
star
78

concourse-example-rails

T ๅฎข้‚ฆ 2017 ๅนด้ตไบบ่ณฝ - Concourse ็š„ Deploy ็ฏ„ไพ‹ๅฐˆๆกˆ
Ruby
1
star
79

reactive-pixi-poc

Domain-Driven Design with React + RxJS + PIXI.js (PoC)
TypeScript
1
star
80

setup-mruby

An action to compile mruby
TypeScript
1
star
81

nix-aura

The nix-based universal development environment
Nix
1
star
82

snake-online

A simple snake game online version
JavaScript
1
star
83

mini-cinema-bot

The LINE bot for query cinema information
Ruby
1
star