我的堆棧看起來像這樣nginx - > thin - > rails。在我的Rails應用程序我在applicaton_controller.rb:使用nginx在rails中強制ssl登錄用戶
if (!Rails.env.development?)
before_filter :force_ssl
end
# Force logged in users to use SSL
def force_ssl
if current_user && request.protocol != "https://"
redirect_to :protocol => "https://"
end
end
的問題是所有請求看起來像HTTP,因爲nginx的處理SSL並轉發到薄,導致無限重定向循環。在這種情況下,爲登錄用戶設置ssl的正確方法是什麼?
1.損害緩存,2需要SSL協議(並非無足輕重,如果你考慮到頁面上使用的各個領域:礦山,谷歌分析,谷歌CDN,我的CDN,臉譜,微博等),3.不標準的做法。我不知道谷歌是否這樣(http://www.google.com仍然適用於我) – jhchen