FIX: remove hardcoding from middleware stack so we can control it

This commit is contained in:
Sam 2014-07-10 17:01:21 +10:00
parent 5032c96486
commit 6019e3f257
4 changed files with 1 additions and 22 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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