Local development with SSL and Puma

Updated . Posted . Visible to the public.

Sometimes the need arises for SSL in local development. We have guides for different webservers, this one is for puma.

  1. make sure mkcert is installed

  2. create an SSL certificate for localhost with mkcert:

$ mkcert-v1.4.4-linux-amd64 localhost
Created a new local CA 💥
...
  1. use the certificate in the Puma config config/puma.rb:
localhost_key = "#{File.join('localhost-key.pem')}"
localhost_crt = "#{File.join('localhost.pem')}"

ssl_bind '0.0.0.0', 3000, {
  key: localhost_key,
  cert: localhost_crt,
  verify_mode: 'none'
}
  1. start your server as usual, but go to https://localhost:3000
bundle exec rails s
  1. Accept the certificate in your browser
Daniel Straßner
Last edit
Daniel Straßner
Keywords
HTTPS
License
Source code in this card is licensed under the MIT License.
Posted by Daniel Straßner to makandra dev (2022-08-18 07:23)