Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialQuinton Casburn
15,201 PointsDoes anyone know how to deploy a rails app using https?
I have a rails app that I am trying to deploy with https but haven't been able to successfully configure my server with the tutorials I've found and the workshop on treehouse that covers how to deploy an app only covers how to deploy with http.
Server: ubuntu 16.04 rails app ruby 2.3.0 rails 5.1.4 unicorn ngnix
1 Answer
Ari Misha
19,323 PointsHiya there! HTTPS is the most secure way , encrypted version of HTTP. If you'd like to migrate to HTTPS from HTTP, you're gonna have get a SSL certificate. Now, this process may or may not require for you to spend some cash. But there are few sites which provides free SSL certificates. My fave one is LetsEncrypt.
Now the second step would be to configure the web server to use the SSL certificate. Concatenate all SSL files and the private key using a Text Editor or use cat on UNIX. Since i mostly use Heroku for my server. Here is how its done using terminal:
$ heroku addons:create ssl:endpoint
Now install the SSL certificate using the private key and the full SSL bundle , which was originally composed by the certificate
$ heroku certs:add certificate_and_chain.pem private.key
The final step is to make some changes in the Rails's config file itself. In Rails >= 3.1 , there is a configuration flag called force_ssl. Dig into config/environments/production.rb , make the following change:
Rails.application.configure do |config|
......
config.force_ssl = true
end
Restart your web server to apply the changes. If you're on Rails < 3.1 , you might wanna install rack_ssl gem and make some changes to your production configuration and you're good to go. I hope it helped!
~ Ari