I am trying to configure a Rails application with SSL, using Nginx and Unicorn. I am trying to set it up locally. For that I first created a self-signed certificate using OpenS
You are missing a header:
proxy_set_header X-Forwarded-Proto https;
Let me cite a comprehensive post that explains nicely how Rails deals with HTTPS on Nginx:
force_sslrelies on theHTTP_X_FORWARDED_PROTOHTTP header to determine whether or not the request was an HTTPS request. If this setting isn't set tohttpsthen you will end up with an infinite redirect loop asforce_sslwill always think the forwarded request isn't HTTPS.
Copying the answer from the comments in order to remove this question from the "Unanswered" filter:
Try changing 'rewrite ^/(.*) http://...' to 'rewrite ^/(.*) https://...' and remove listen 80 from the 2nd server block
~ answer per house9