kastner (owner)

Forks

Revisions

gist: 222370 Download_button fork
public
Public Clone URL: git://gist.github.com/222370.git
Embed All Files: show embed
/lib/xhost.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
module Rack
  # Apache and others set HTTP_X_FORWARDED_HOST for proxied connections
  # This middleware detects it and makes it look like the HOST
  
  class XHost
    def initialize(app)
      @app = app
    end
    
    def call(env)
      env["HTTP_HOST"] = env["HTTP_X_FORWARDED_HOST"] if env["HTTP_X_FORWARDED_HOST"]
      @app.call(env)
    end
  end
end