Last active
December 31, 2021 11:01
-
-
Save kseki/bdd31b60f3ce1efff7846849687b26ea to your computer and use it in GitHub Desktop.
Localhost gem for SSL(https) connection in the Rails development environment.
This file contains hidden or 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
gem 'rails' | |
gem 'puma' | |
# 1. Add localhost gem. | |
group(:development) do | |
gem 'localhost' | |
end |
This file contains hidden or 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
# config/puma.rb | |
# 2. Add SSL bind setting | |
require 'localhost/authority' | |
authority = Localhost::Authority.fetch | |
ssl_bind '127.0.0.1', '3001', { | |
key: authority.key_path, | |
cert: authority.certificate_path | |
} | |
# 3. Comment out this line | |
# port ENV.fetch("PORT") { 3000 } |
This file contains hidden or 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
$ rails server | |
=> Booting Puma | |
=> Rails 7.0.0 application starting in development | |
=> Run `bin/rails server --help` for more startup options | |
Puma starting in single mode... | |
* Puma version: 5.5.2 (ruby 3.0.2-p107) ("Zawgyi") | |
* Min threads: 5 | |
* Max threads: 5 | |
* Environment: development | |
* PID: 79764 | |
* Listening on ssl://127.0.0.1:3000?cert=/Users/kseki/.localhost/localhost.crt&key=/Users/kseki/.localhost/localhost.key&verify_mode=none | |
Use Ctrl-C to stop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment