From 5242a49c023314f289ffe25900195d28f026fd69 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 10 Jan 2014 12:20:52 +1100 Subject: [PATCH] BUGFIX: in some proxy scenarios https was not propergated properly --- config/initializers/50-force_https.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 config/initializers/50-force_https.rb diff --git a/config/initializers/50-force_https.rb b/config/initializers/50-force_https.rb new file mode 100644 index 000000000..161bc8cc4 --- /dev/null +++ b/config/initializers/50-force_https.rb @@ -0,0 +1,17 @@ +# tiny middleware to force https if needed +class Discourse::ForceHttpsMiddleware + + def initialize(app, config={}) + @app = app + end + + def call(env) + env['rack.url_scheme'] = 'https' if SiteSetting.use_https + @app.call(env) + end + +end + + +Rails.configuration.middleware.insert_before MessageBus::Rack::Middleware, Discourse::ForceHttpsMiddleware +