@@ -56,6 +56,12 @@ def app
56
56
a_request ( :get , 'http://example.com/test/stuff' ) . with ( :headers => { "Host" => "example.com" } ) . should have_been_made
57
57
end
58
58
59
+ it "should set the X-Forwarded-Host header to the proxying host by default" do
60
+ stub_request ( :any , 'example.com/test/stuff' )
61
+ get '/test/stuff'
62
+ a_request ( :get , 'http://example.com/test/stuff' ) . with ( :headers => { 'X-Forwarded-Host' => 'example.org' } ) . should have_been_made
63
+ end
64
+
59
65
describe "with preserve host turned off" do
60
66
def app
61
67
Rack ::ReverseProxy . new ( dummy_app ) do
@@ -71,18 +77,19 @@ def app
71
77
end
72
78
end
73
79
74
- describe "with x_forwarded_host turned on " do
80
+ describe "with x_forwarded_host turned off " do
75
81
def app
76
82
Rack ::ReverseProxy . new ( dummy_app ) do
77
- reverse_proxy_options :x_forwarded_host => true
83
+ reverse_proxy_options :x_forwarded_host => false
78
84
reverse_proxy '/test' , 'http://example.com/'
79
85
end
80
86
end
81
87
82
- it "should optionally set the X-Forwarded-Host header to the proxying host" do
88
+ it "should not set the X-Forwarded-Host header to the proxying host" do
83
89
stub_request ( :any , 'example.com/test/stuff' )
84
90
get '/test/stuff'
85
- a_request ( :get , 'http://example.com/test/stuff' ) . with ( :headers => { 'X-Forwarded-Host' => 'example.org' } ) . should have_been_made
91
+ a_request ( :get , 'http://example.com/test/stuff' ) . with ( :headers => { 'X-Forwarded-Host' => 'example.org' } ) . should_not have_been_made
92
+ a_request ( :get , 'http://example.com/test/stuff' ) . should have_been_made
86
93
end
87
94
end
88
95
0 commit comments