Run a Rails server on https and localhost

0

openssl req -x509 -sha256 -nodes -newkey rsa:2048 -days 365 -keyout localhost.key -out localhost.crt

then

rails s -b 'ssl://localhost:3000?key=localhost.key&cert=localhost.crt'

This will give you lots of red warnings which you can ignore. If you want to avoid that then do this instead

brew install mkcert
mkcert localhost
mkcert -install
rails s -b 'ssl://localhost:3000?key=localhost-key.pem&cert=localhost.pem'

or to run Rails in production mode on localhost and http

rails s -e production -b 'ssl://localhost:3000?key=localhost-key.pem&cert=localhost.pem'

  • 0 posts
  • 0 subtopics
  • 13 days ago by vince