, SSL Rails, , HTTP HTTPS , , , .
>= 3.1
config.force_ssl = true .
module MyApp
class Application < Rails::Application
config.force_ssl = true
end
end
https Rails. , HTTPS /.
module MyApp
class Application < Rails::Application
config.force_ssl = false
end
end
MyApp::Application.configure do
config.force_ssl = true
end
Rails < 3.1
, Rails 3.1, . HTTPS, .
config.middleware.insert_before ActionDispatch::Static, "Rack::SSL"
, Im Rack::SSL , Rails. , , ActionDispatch::Static ActionDispatch::Cookies.
Rack:: SSL Gemfile.
gem 'rack-ssl', :require => 'rack/ssl'
HTTPS HTTP
Rack::SSL . :exclude, , / HTTPS.
Rack::SSL , HTTPS-.
config.middleware.insert_before ActionDispatch::Static, Rack::SSL, :exclude => proc { |env| env['HTTPS'] != 'on' }
URL- , Rack::SSL.
https://secure.example.com
http://example.com