如何设置本地SSL证书和Rails应用程序?

这可能是一个二合一的问题。

  1. 我有一个用于家庭/爱好使用的Rails应用程序,托管在Raspberry Pi上,我想知道是否可以为它创建本地SSL证书并设置Rails使用它?

  2. 如果是,我如何设置我的Rails / Puma / Foreman / Ubuntu应用程序? 现在,我使用Procfile运行Foreman的应用程序:

    web: bundle exec puma -t 8:8 -p 3000 worker: bundle exec sidekiq clock: bundle exec clockwork config/clock.rb 

  1. 是的你可以。 这是一个解释过程的要点:

https://gist.github.com/tadast/9932075

  1. 我的procfile包含一个如下所示的条目:

    server:rails server puma -b’sssl://0.0.0.0:3000?key = server.key&cert = server.crt’

这似乎对我有用。 我也定了

 config.force_ssl = true 

在config / application.rb中

我从所有这些地方收集了有关它的信息:

https://github.com/puma/puma

http://www.railway.at/2013/02/12/using-ssl-in-your-local-rails-environment/

http://www.panozzaj.com/blog/2013/08/12/how-to-set-up-local-https-development/

http://www.eq8.eu/blogs/14-config-force_ssl-is-different-than-controller-force_ssl