How can I setup a local SSL certificate and a Rails application?

江枫思渺然 提交于 2019-12-18 06:54:52

问题


This might be a two-in-one question.

  1. I have a Rails application for home/hobby usage, hosted on a Raspberry Pi and I was wondering if it's possible to create a local SSL certificate for it and setup Rails to use it?

  2. If yes, how can I setup my Rails/Puma/Foreman/Ubuntu application? For now, I am running the application with Foreman, by using a Procfile:

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

回答1:


  1. Yes you can. Here is a gist explaining the process:

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

  1. My procfile contains an entry that looks like this:

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

This seems to work for me. I also set

config.force_ssl = true 

in config/application.rb

I gathered info about it from all these places:

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



来源:https://stackoverflow.com/questions/34991868/how-can-i-setup-a-local-ssl-certificate-and-a-rails-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!