4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Rails + Pumaの開発環境をSSL化

Posted at

ローカルの開発環境をSSL化したメモ

自己署名証明書を発行

opensslを使用

ssh.log
user:hoge $ mkidr tmp/   # プロジェクト配下に適当なディレクトリを作成
user:hoge $ cd tmp/
user:tmp $ openssl genrsa 2048 > server.key
user:tmp $ openssl req -new -key server.key > server.csr  # 色々聞かれるので、適当に答える
Country Name (2 letter code) [AU]:***
State or Province Name (full name) [Some-State]:***
Locality Name (eg, city) []:***
Organization Name (eg, company) [Internet Widgits Pty Ltd]:***
Organizational Unit Name (eg, section) []:***
Common Name (e.g. server FQDN or YOUR name) []:**
Email Address []:******
A challenge password []:*********
An optional company name []:*******
user:tmp $ openssl x509 -days 3650 -req -signkey server.key < server.csr > server.crt

pumaの設定変更

pumaに以下を追記する
(ポート番号は好きな番号で)

puma.rb
if 'development' == ENV.fetch('RAILS_ENV') { 'development' }
  ssl_bind '0.0.0.0', '5001', {
    key: 'tmp/server.key',
    cert: 'tmp/server.crt',
    verify_mode: "none"
  }
end

起動

rails s ではなく、 bundle exec pumactl startで起動する
(pumaの設定を読み込むため)
最後に https://でアクセスしてみて確認

最後に

bundle exec pumactl start
でpumaを起動すると、別でターミナルを起動して、 tail -fをしないとログがみれないので、
ちょっと不便になる。。

4
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?