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

时间:2016-01-25 11:48:50

标签: ruby-on-rails ruby ssl puma foreman

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

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

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

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

1 个答案:

答案 0 :(得分:7)

  1. 是的,你可以。这是一个解释过程的要点:
  2. https://gist.github.com/tadast/9932075

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

      服务器:rails服务器puma -b'sssl://0.0.0.0:3000?key = server.key& cert = server.crt'

    2. 这似乎对我有用。我也设置了

      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