Skip to content

Commit 9f13473

Browse files
committed
added a test for accessing $proxy_host and $proxy_port in Lua. this test requires the proxy_host_port_vars patch for the nginx core to pass. thanks saravsars for the report in openresty#301.
1 parent b361a10 commit 9f13473

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

t/045-ngx-var.t

+26-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use t::TestNginxLua;
88

99
repeat_each(2);
1010

11-
plan tests => repeat_each() * (blocks() * 2 + 2);
11+
plan tests => repeat_each() * (blocks() * 2 + 4);
1212

1313
#no_diff();
1414
#no_long_string();
@@ -153,3 +153,28 @@ invalid referer: 1
153153
--- no_error_log
154154
[error]
155155

156+
157+
158+
=== TEST 8: $proxy_host & $proxy_port
159+
--- config
160+
location = /t {
161+
proxy_pass http://127.0.0.1:$server_port/back;
162+
header_filter_by_lua '
163+
ngx.header["Proxy-Host"] = ngx.var.proxy_host
164+
ngx.header["Proxy-Port"] = ngx.var.proxy_port
165+
';
166+
}
167+
168+
location = /back {
169+
echo hello;
170+
}
171+
--- request
172+
GET /t
173+
--- raw_response_headers_like
174+
Proxy-Host: 127.0.0.1\:\d+\r
175+
Proxy-Port: \d+\r
176+
--- response_body
177+
hello
178+
--- no_error_log
179+
[error]
180+

0 commit comments

Comments
 (0)