问题
This might be a two-in-one question.
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?
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:
- Yes you can. Here is a gist explaining the process:
https://gist.github.com/tadast/9932075
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