Skip to content

Commit

Permalink
Merge pull request #210 from mlibrary/ingress-workaround
Browse files Browse the repository at this point in the history
Add a middleware to force the HTTP Host
  • Loading branch information
botimer authored Sep 23, 2024
2 parents fcd9536 + 0fdfb21 commit 64b3daf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
3 changes: 0 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,6 @@ GEM
nio4r (~> 2.0)
racc (1.6.2)
rack (2.2.6.4)
rack-cors (2.0.2)
rack (>= 2.0.0)
rack-test (2.1.0)
rack (>= 1.3)
rails (5.2.8.1)
Expand Down Expand Up @@ -481,7 +479,6 @@ DEPENDENCIES
pry-rails
puma (>= 4.3.5)
rack (>= 2.1.4)
rack-cors
rails (~> 5.0)
rake (~> 13.0)
rsolr (>= 1.0)
Expand Down
13 changes: 13 additions & 0 deletions config/initializers/explicit_proxy_host.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class ExplicitProxyHost
def initialize(app)
@app = app
@host = ENV['RAILS_URL_HOST']
end

def call(env)
env['HTTP_X_FORWARDED_HOST'] = @host unless @host.nil?
@app.call(env)
end
end

Rails.application.config.middleware.insert_before 0, ExplicitProxyHost

0 comments on commit 64b3daf

Please sign in to comment.