How does Nginx pass SSL encrypted data to a Rails app?

nginx, ruby-on-rails, ssl

Solution

That's called nginx ssl termination. The data is already decrypted by nginx and the upstream rails app just need to deal with unencrypted data, i.e., you rails app should just listen to port 80 (http) and in your reverse proxy setup, you should have

proxy_pass http://rails_app_domain;

NOT

proxy_pass https://rails_app_domain;

Problem

Suppose I have a setup running my Rails app with Unicorn and using Nginx as the reverse proxy. When Nginx is configured to handle SSL does that mean it passes the encrypted data to my Rails app directly unchanged or does it decrypt it and then send that to my Rails app, so that my Rails app sees unencrypted data?

Original source