Last active
April 7, 2022 14:46
-
-
Save dryaf/de6673c57b20b5aaf1861e5a3504be05 to your computer and use it in GitHub Desktop.
Use SSL in Development-Mode in Ruby on Rails 7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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