From 1e1e09304dd2d2c8e534929ad0a3dc47bd54d03f Mon Sep 17 00:00:00 2001 From: Behrang Javaherian Date: Thu, 2 Feb 2012 11:21:25 +1100 Subject: [PATCH] Handle HTTP_X_FORWARDED_PROTO header for https --- lib/omniauth/strategy.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/omniauth/strategy.rb b/lib/omniauth/strategy.rb index 5f61e27..c080514 100644 --- a/lib/omniauth/strategy.rb +++ b/lib/omniauth/strategy.rb @@ -376,6 +376,8 @@ module OmniAuth uri = URI.parse(request.url.gsub(/\?.*$/,'')) uri.path = '' uri.query = nil + #sometimes the url is actually showing http inside rails because the other layers (like nginx) have handled the ssl termination. + uri.scheme = 'https' if(request.env['HTTP_X_FORWARDED_PROTO'] == 'https') uri.to_s end end