2016-08-18 3 views
2

Railsブログを設定しています。私はRails 5とDevise 4.2.0を使用しています。このアプリは、NginxとPumaを搭載したUbuntu Server上で稼働し、Capistranoと共に展開されます。 NginxでHTTPS(有効なSSL証明書付き)を有効にし、301のリダイレクトフォームHTTPをHTTPSに追加するまでは、すべてが実動的に機能します。Devise:サーバーでHTTPSが有効になっている(JSON/APIなし)

プロダクションログを確認しましたが、ログの真正性キーがブラウザに表示されているものと一致しません。ここで

は、私が使用していますnginx.confファイルです:

upstream puma { 
    server unix:///home/deploy/apps/example-blog/shared/tmp/sockets/example-blog-puma.sock; 
} 

server { # Redirect HTTP to HTTPS 
 # Bind port(s) 
 listen   80; 
 listen   [::]:80; 

 # Bind domain(s) 
 server_name blog.example.com; 

 # 301 redirect to HTTPS 
 return 301 https://$server_name$request_uri; 
} 

server { # Primary server block 
 # Bind port(s) 
 listen   443 default_server ssl; 

 # Bind domain(s) 
 server_name blog.example.com; 

 # Bind certificate(s) 
 ssl_certificate       /etc/nginx/ssl/blog.example.com/ssl-bundle.crt; 
 ssl_certificate_key   /etc/nginx/ssl/blog.example.com/blog.example.com.key; 

 root /home/deploy/apps/example-blog/current/public; 
 access_log /home/deploy/apps/example-blog/current/log/nginx.access.log; 
 error_log /home/deploy/apps/example-blog/current/log/nginx.error.log info; 

 location ^~ /assets/ { 
   gzip_static on; 
   expires max; 
   add_header Cache-Control public; 
 } 

 try_files $uri/index.html $uri @puma; 
 location @puma { 
   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
   proxy_set_header Host $http_host; 
   proxy_redirect off; 

   proxy_pass http://puma; 
 } 

 error_page 500 502 503 504 /500.html; 
 client_max_body_size 10M; 
 keepalive_timeout 10; 
} 

誰もがここで起こっかもしれないものを知っていますか? 詳細情報が必要な場合はお知らせください。

おかげで行くそれを得たlocation @puma

答えて

5

追加proxy_set_header X-Forwarded-Proto $scheme;

+0

ありがとう、それは私の日を節約します。私はまったく同じ問題を抱えていました。あなたのソリューションは魅力的に機能します。説明は? –

+0

@CupraR_On_Rails私が理解しているように、Railsアプリケーションは、要求が入ったHTTPプロトコルを確認することができ、認証トークンを生成するときに使用されます。 – slehmann36

+0

ありがとう、ありがとう。 –

関連する問題