Sources:
- Create self-signed SSL certificate
cd
mkdir .ssl
cd .ssl
# enter localhost.ssl as Common Name
openssl req -new -newkey rsa:2048 -sha256 -days 365 -nodes -x509 -keyout localhost.key -out localhost.crt
- Add localhost.ssl to /etc/hosts
echo "127.0.0.1 localhost.ssl" | sudo tee -a /etc/hosts
- Modify config of Rails app
# config/environments/development.rb
config.force_ssl = true
# show server log like running server with 'rails s' command
logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
- Run server
thin start -p 3000 --ssl --ssl-key-file ~/.ssl/localhost.key --ssl-cert-file ~/.ssl/localhost.crt
- Access web app with https protocol
Open browser and access https://localhost.ssl:3000/.