Too many redirects error while trying to configure rails application as SSL using nginx and unicorn

前端 未结 2 899
星月不相逢
星月不相逢 2021-02-04 03:42

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

2条回答
  •  [愿得一人]
    2021-02-04 04:20

    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_ssl relies on the HTTP_X_FORWARDED_PROTO HTTP header to determine whether or not the request was an HTTPS request. If this setting isn't set to https then you will end up with an infinite redirect loop as force_ssl will always think the forwarded request isn't HTTPS.

提交回复
热议问题