Sometimes the need arises for SSL in local development. We have guides for different webservers, this one is for puma.
-
make sure mkcert is installed
-
create an SSL certificate for localhost with mkcert:
$ mkcert-v1.4.4-linux-amd64 localhost
Created a new local CA 💥
...
- 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'
}
- start your server as usual, but go to
https://localhost:3000
bundle exec rails s
Posted by Daniel Straßner to makandra dev (2022-08-18 07:23)