4

I've got our Ruby on Rails app up and running on Heroku using HTTP. Now it's time to use HTTPS during the login process and for all transactions after the user is logged in. But I'm not sure where to start.

configuration

We're using:

Ruby (1.9.2)
Rails (3.0.5)
Devise (1.5.3)

Our domain (registered by GoDaddy) is oursite.com (not its real name), which resolves to oursite.herokuapp.com. I want secure transactions to be performed in a subdomain https://secure.oursite.com. I've purchased an SSL certificate from GoDaddy, created the key files, signed up for the Zerigo DNS service and set oursite.com nameservers to point at Zergo's servers. And on Heroku, I've done:

heroku domains:add secure.oursite.com
heroku ssl:add final.crt site.key
heroku addons:add ssl:hostname

the questions

  • If a user arrives at our site under http://oursite.com, how (and when) do I switch to https://secure.oursite.com?
  • How do I enforce using https for any secure transaction (e.g. submitting a password)?
  • How does one test this stuff using localhost:3000?

Concrete answers, general answers, and pointers to tutorials and examples are equally welcome. Thanks!

fearless_fool
  • 33,645
  • 23
  • 135
  • 217

2 Answers2

9

First:

redirecting from http://example.com to https://example.mysite.com

... is a very specific question that supersedes this very general question. I'll summarize the best bits of info I found in the last 24 hours, as it may be helpful to someone else.

Hope this is helpful...

Community
  • 1
  • 1
fearless_fool
  • 33,645
  • 23
  • 135
  • 217
1

I would have a look at ssl_requirement. This allows you to secure various parts of your application thus forcing you to only serve certain pages over HTTPS.

https://github.com/rails/ssl_requirement

With local development, you'll need to setup some sort of Apache / NGinx setup with a locally signed cert bolted on. A quick google uncovered this:

http://www.subelsky.com/2007/11/testing-rails-ssl-requirements-on-your.html

Neil Middleton
  • 22,105
  • 18
  • 80
  • 134
  • Thanks -- ssl_requirement looks simple and elegant. have I made my life more difficult by specifying the SSL cert for secure.oursite.com (rather than just oursite.com)? I can undo that, I suppose. – fearless_fool Jan 25 '12 at 19:03
  • Waitaminnit -- it appears that ssl_requirement is no longer appropriate for Rails 3 -- see http://stackoverflow.com/questions/3634100/rails-3-ssl-deprecation . On the other hand, that same link suggests the appropriate alternative. – fearless_fool Jan 25 '12 at 21:22