File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ def call(env)
25
25
}
26
26
headers [ 'HOST' ] = uri . host if all_opts [ :preserve_host ]
27
27
headers [ 'X-Forwarded-Host' ] = rackreq . host if all_opts [ :x_forwarded_host ]
28
-
28
+
29
29
session = Net ::HTTP . new ( uri . host , uri . port )
30
30
session . read_timeout = all_opts [ :timeout ] if all_opts [ :timeout ]
31
31
Original file line number Diff line number Diff line change @@ -71,6 +71,21 @@ def app
71
71
end
72
72
end
73
73
74
+ describe "with x_forwarded_host turned on" do
75
+ def app
76
+ Rack ::ReverseProxy . new ( dummy_app ) do
77
+ reverse_proxy_options :x_forwarded_host => true
78
+ reverse_proxy '/test' , 'http://example.com/'
79
+ end
80
+ end
81
+
82
+ it "should optionally set the X-Forwarded-Host header to the proxying host" do
83
+ stub_request ( :any , 'example.com/test/stuff' )
84
+ get '/test/stuff'
85
+ a_request ( :get , 'http://example.com/test/stuff' ) . with ( :headers => { 'X-Forwarded-Host' => 'example.org' } ) . should have_been_made
86
+ end
87
+ end
88
+
74
89
describe "with basic auth turned on" do
75
90
def app
76
91
Rack ::ReverseProxy . new ( dummy_app ) do
You can’t perform that action at this time.
0 commit comments