This thread makes a good start, but I still have questions. What does force_ssl do in Rails?
All of this is in reference to what happens when you set
config.force_ssl = true
in your production.rb
file.
It makes sense to make your SSL-endpoint your server (say nginx). From that standpoint, I get that nginx will need access to the SSL certificate's private key in order to be able to decrypt the encrypted SSL traffic. This is my very rough understanding.
From there, the server can send that information to the Rails app (through, say puma server), via http and then the Rails app will work on the unencrypted request, create the necessary content to send back, and then send it back up the chain where it will be re-encrypted by the server (nginx) and sent back to the user.
That's my loose understanding.
- IF this is [generally] how it works, then how does Rails know when to force a redirect to https if its getting the request as http?
- IF this is NOT [generally] how it works, and Rails is actually decrypting the payload, then how can it do that without the private key for the SSL cert?