简体   繁体   中英

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

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. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM