Skip to content

Instantly share code, notes, and snippets.

@dryaf
Last active April 7, 2022 14:46
Show Gist options
  • Save dryaf/de6673c57b20b5aaf1861e5a3504be05 to your computer and use it in GitHub Desktop.
Save dryaf/de6673c57b20b5aaf1861e5a3504be05 to your computer and use it in GitHub Desktop.
Use SSL in Development-Mode in Ruby on Rails 7
# rm -rf config/certs
brew install mkcert
mkdir -p config/certs
mkcert localhost
mv *.pem config/certs
cat << EOF
# for Rails 7, config/puma.rb - replace port ENV.fetch("PORT") { 3000 } with this
if ENV.fetch("RAILS_ENV", "development") == "development"
ssl_bind(
'0.0.0.0',
ENV.fetch("PORT") { 3000 },
key: ENV.fetch('SSL_KEY_FILE', 'config/certs/localhost-key.pem'),
cert: ENV.fetch('SSL_CERT_FILE', 'config/certs/localhost.pem'),
verify_mode: 'none'
)
else
port ENV.fetch("PORT") { 3000 }
end
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment