質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.46%
Ruby on Rails 5

Ruby on Rails 5は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Q&A

解決済

1回答

1461閲覧

Localhostにてhttps接続をしたい

Yoshino0001

総合スコア6

Ruby on Rails 5

Ruby on Rails 5は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

0グッド

0クリップ

投稿2021/04/22 02:42

前提・実現したいこと

Ruby on Railsにてアプリケーションを作成中です。
Localhostでも、HTTPSを有効にしたいと考えています。
webサーバーはpumaを使用。httpsの環境構築にmkcertを使用。

railsのlocal環境をhttpsにしてみた。
上記記事の指示内容を完全にトレース。

だが、https://localhost:9292で接続できず。

発生している問題・エラーメッセージ

ブラウザ上では、**「このサイトにアクセスできませんlocalhost により途中で接続が切断されました。」**とエラーが出ます。

また、rails s した際には、
Listening onssl://0.0.0.0:9292cert=./localhost.pem&key=./localhostkey.pem&verify_mode=noneというログが出ました。

該当のソースコード

#config/puma.rb workers Integer(ENV['WEB_CONCURRENCY'] || 2) threads_count = Integer(ENV['RAILS_MAX_THREADS'] || 5) threads threads_count, threads_count preload_app! rackup DefaultRackup port ENV['PORT'] || 3000 environment ENV['RACK_ENV'] || 'development' on_worker_boot do # Worker specific setup for Rails 4.1+ # See: https://devcenter.heroku.com/articles/ # deploying-rails-applications-with-the-puma-web-server#on-worker-boot ActiveRecord::Base.establish_connection end if ENV.fetch('RAILS_ENV') { 'development' } == 'development' ssl_bind '0.0.0.0', '9292', key: './localhost-key.pem', cert: './localhost.pem' end
#config/environments/development.rb Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. config.cache_classes = false # Do not eager load code on boot. config.eager_load = false # Show full error reports. config.consider_all_requests_local = true # Enable/disable caching. By default caching is disabled. # Run rails dev:cache to toggle caching. if Rails.root.join('tmp', 'caching-dev.txt').exist? config.action_controller.perform_caching = true config.cache_store = :memory_store config.public_file_server.headers = { 'Cache-Control' => "public, max-age=#{2.days.to_i}" } else config.action_controller.perform_caching = false config.cache_store = :null_store end # Store uploaded files on the local file system (see config/storage.yml for options) config.active_storage.service = :local # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = true config.action_mailer.delivery_method = :test config.action_mailer.default_url_options = { host: 'localhost:3000', protocol: 'http' } config.action_mailer.perform_caching = false # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log # Raise an error on page load if there are pending migrations. config.active_record.migration_error = :page_load # Highlight code that triggered database queries in logs. config.active_record.verbose_query_logs = true # Debug mode disables concatenation and preprocessing of assets. # This option may cause significant delays in view rendering with a large # number of complex assets. config.assets.debug = true # Suppress logger output for asset requests. config.assets.quiet = true # Raises error for missing translations # config.action_view.raise_on_missing_translations = true # Use an evented file watcher to asynchronously detect changes in source code, # routes, locales, etc. This feature depends on the listen gem. config.file_watcher = ActiveSupport::EventedFileUpdateChecker end

試したこと

サーバーの再起動、mkcertの再インストールなど。

補足情報

Rails学習開始から1ヶ月ほどです。初心者なので、お手柔らかにしていただけると幸いです。
よろしくお願いします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

自己解決

解決しました!!

firefoxをブラウザに指定したところ接続を確認。

mkcert -installのコマンドで、mkcertの認証局を作成した際に、以下のログが出現。
The local CA is now installed in the Firefox trust store (requires browser restart)!

chromeではなく、firefoxでhttps接続ができるようになっていた。
初歩的なミスでした。
コンソールのログはよく見るように心がけます。

ありがとうございました!!

投稿2021/04/22 07:40

Yoshino0001

総合スコア6

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.46%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問