diff --git a/app/controllers/static_controller.rb b/app/controllers/static_controller.rb index 12be4fd0308..bf2764d28fe 100644 --- a/app/controllers/static_controller.rb +++ b/app/controllers/static_controller.rb @@ -76,7 +76,7 @@ class StaticController < ApplicationController # we must disable acceleration otherwise NGINX strips # access control headers - request.env['_disable_accl'] = true + request.env['sendfile.type'] = '' send_file(path, opts) end end diff --git a/config/application.rb b/config/application.rb index 674a240be17..1922a73d5a5 100644 --- a/config/application.rb +++ b/config/application.rb @@ -122,13 +122,6 @@ module Discourse # supports etags (post 1.7) config.middleware.delete Rack::ETag - # We need to be able to disable for cdn assets - # x-accl-redirect strips headers we need to forward - # issue open since 2008 - require 'middleware/optional_sendfile' - config.middleware.insert_after Rack::Sendfile, Middleware::OptionalSendfile, config.action_dispatch.x_sendfile_header - config.middleware.delete Rack::Sendfile - # route all exceptions via our router config.exceptions_app = self.routes diff --git a/config/environments/production.rb b/config/environments/production.rb index 5028919d26c..5ce1abeace1 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -21,9 +21,6 @@ Discourse::Application.configure do # Generate digests for assets URLs config.assets.digest = true - # Specifies the header that your server uses for sending files - config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx - # Enable locale fallbacks for I18n (makes lookups for any locale fall back to # the I18n.default_locale when a translation can not be found) config.i18n.fallbacks = true diff --git a/lib/middleware/optional_sendfile.rb b/lib/middleware/optional_sendfile.rb deleted file mode 100644 index 9eb21c56f61..00000000000 --- a/lib/middleware/optional_sendfile.rb +++ /dev/null @@ -1,11 +0,0 @@ -module Middleware - class OptionalSendfile < Rack::Sendfile - def call(env) - if env["_disable_accl"] == true - @app.call(env) - else - super(env) - end - end - end -end